High Dynamic Range Imaging

Topics Covered

High Dynamic Range Imaging (HDRI) is a technique used to capture and display images with a greater range of brightness and color than traditional images. It is achieved by capturing multiple exposures of the same scene and then merging them together using specialized software. The resulting image contains a higher level of detail and a wider range of color and brightness, making it look more realistic and visually appealing. HDRI is widely used in photography, film-making, and video game development.

Pre-requisites

To learn HDR imaging using OpenCV, the following prerequisites are recommended:

  • Basic understanding of computer vision concepts such as image processing, filtering, and manipulation.
  • Familiarity with the C++ or Python programming language, as OpenCV provides APIs in both languages.
  • Understanding of digital imaging concepts such as pixel values, colour spaces, and image compression.
  • Basic knowledge of linear algebra and calculus, which are used in some HDR imaging techniques.
  • Familiarity with the OpenCV library and its functionalities, including image loading and saving, image filtering, and image display.
  • Experience with software development tools, such as an IDE and version control system, is helpful.

The foundation of high dynamic range imaging is the idea that the human eye can distinguish between a broader range of brightness and colour than a camera can in a single exposure. Several photographs of the same scene are taken at various exposures, from underexposed to overexposed, to make an HDRI image. A final image with a larger range of brightness and colour is produced by merging these photos using specialist software.

Tone mapping, a method for combining photos, includes adjusting the brightness and contrast of the image to get a more realistic-looking outcome. Depending on the intended application, the final image can be saved in several formats, including JPEG, TIFF, and EXR.

What is High Dynamic Range Imaging?

When compared to conventional photographs, high dynamic range imaging (HDRI) allows for a wider range of brightness and colour to be captured and displayed. It is accomplished by taking many exposures of the same scene and then using specialist software to combine them. The outcome is an image with more detail, a larger range of colour and brightness, and a more aesthetically pleasing appearance.

Conventional photographs can only capture a tiny range of brightness and colour because of their limited dynamic range. This may cause sections of an image to be overexposed or underexposed, losing information. This restriction is overcome by HDRI by taking numerous exposures of the same image and combining them to create a final image and colour.

HDRI-on

Low vs. High Dynamic Range Imaging

The conventional technique for taking and showing pictures is called low dynamic range imaging (LDRI). LDRI photographs only record a narrow range of brightness and colour because of their low dynamic range. This may cause sections of an image to be overexposed or underexposed, losing information.

High Dynamic Range Imaging pictures, on the other hand, may capture a far larger range of brightness and colour because they have a much wider dynamic range. This enables the final image to have more detail and realism. Several exposures of the same picture at various exposure settings are taken to create HDRI, which is then combined using specialist software.

LDRI is suitable for many applications, such as standard photography, where a limited dynamic range is sufficient. However, for applications such as film-making, video game development, and scientific imaging, where a greater level of detail and realism is required, HDRI is the preferred method.

Here is a table comparing Low Dynamic Range Imaging (LDRI) and High Dynamic Range Imaging (HDRI):

AspectLDRIHDRI
Dynamic rangeLimitedWide
Exposure levels capturedSingle exposureMultiple exposures
Detail capturedLimitedHigh
Over/underexposurePossibleMinimized
Image format supportCommon formats (JPEG, PNG, etc.)Specialized formats (HDR, EXR, etc.)
ApplicationsStandard photography, basic image editingFilm-making, video game development, scientific imaging, advanced editing

LDRI vs HDRI

Advantages of High Dynamic Range Imaging

High dynamic range (HDR) imaging has several advantages, including improved detail in both shadows and highlights, more natural-looking images, and the ability to capture scenes with high contrast. Additionally, HDR images can be used for special effects and to create striking visual compositions.

  • Increased Dynamic Range : HDRI images have a greater dynamic range than traditional images, which means that they can capture a wider range of brightness and color, resulting in more realistic and visually appealing images.
  • Improved Detail : High Dynamic Range Imaging images capture more detail in the highlights, mid-tones, and shadows of a scene, resulting in greater image detail and depth.
  • Minimized Over/Underexposure : HDRI minimizes over and underexposure in images by capturing multiple exposures of the same scene and then merging them to create a final image with a balanced exposure.
  • Increased Flexibility : HDRI images offer greater flexibility in post-processing because they contain more information than traditional images, allowing for more control over the final image.
  • Better Image Quality : HDRI images offer superior image quality, making them ideal for applications such as film-making, video game development, and scientific imaging.

HDR-Image-quality

Disadvantages of High Dynamic Range Imaging

While high dynamic range (HDR) imaging has several advantages, there are also some disadvantages to consider. One potential issue is that HDR images can appear less natural or even surreal if they are not processed carefully.

  • Increased Complexity: HDRI requires more advanced equipment and software than traditional imaging, making it more complex and time-consuming.
  • Learning Curve: High Dynamic Range Imaging has a steeper learning curve than traditional imaging, requiring knowledge of advanced techniques such as exposure bracketing, tone mapping, and colour grading.
  • Increased File Size: HDRI images have larger file sizes than traditional images because they contain more information, requiring more storage space and processing power.
  • Artifacts: HDRI can produce artefacts such as haloing, ghosting, and colour shifts if not properly processed, resulting in an unnatural-looking image.
  • Compatibility: HDRI images may not be compatible with all software and hardware, making them less versatile than traditional images in certain applications.

HDR-Limitations

Types of High Dynamic Range Imaging

Capture-based HDR and display-based HDR are the two main types of HDR, each with its unique advantages and disadvantages.

Capture-based HDR

Capture-based HDR involves capturing multiple images of the same scene at different exposures and merging them to create an image with a wider dynamic range. This technique is often used in photography and cinematography to create images that are more true to life, with greater detail in both the highlights and shadows.

For example, when taking a photograph of a landscape with a bright sky and dark shadows, the camera might struggle to capture all of the detail in both the sky and the shadows. By taking multiple photos at different exposures and merging them using software, you can create an HDR image that accurately captures all of the detail in the scene.

Display-based HDR

Display-based HDR, on the other hand, involves using a display that is capable of producing a wider range of brightness and colour than traditional displays to show HDR content. This type of HDR is often used in televisions and computer monitors to display high-quality video content.

For example, a television with display-based HDR might be able to produce brighter highlights and deeper shadows, resulting in a more immersive viewing experience. This type of HDR is becoming increasingly popular in the entertainment industry, with many streaming services and video games now offering HDR content.

HDR_Demo

High Dynamic Range Imaging in OpenCV

OpenCV is a popular open-source computer vision library that provides a set of tools for image processing and computer vision tasks. OpenCV supports HDR imaging and provides functions for creating and processing HDR images. The library can read and write High Dynamic Range Imaging images in popular file formats such as Radiance HDR and OpenEXR.

OpenCV also provides functions for tone mapping, which is the process of compressing the dynamic range of an HDR image to display it on a device with a lower dynamic range, such as a computer monitor or a mobile phone screen. OpenCV's HDR functions can be used for a variety of applications, such as scientific imaging, computer graphics, and virtual reality.

HDR-in-opencv

Types of Methods in HDR Imaging

  • Mertens HDR : This method is based on the work of Mertens et al. and combines multiple exposures of the same scene to create a single HDR image. It uses an exposure fusion technique to merge the input images and create a single image with a high dynamic range.

  • Debevec HDR : This method is based on the work of Debevec et al. and uses a technique called image-based lighting to create an HDR image. It captures a set of images at different exposure levels and then uses a process called radiance mapping to merge the images into a single HDR image.

  • Robertson HDR : This method is based on the work of Robertson et al. and uses a technique called inverse camera response function estimation to create an HDR image. It captures a set of images at different exposure levels and then estimates the inverse camera response function to merge the images into a single HDR image.

  • Tonemapping : Once an HDR image is created, it must be tonemapped to display on a device with a lower dynamic range, such as a computer monitor or a mobile phone screen. OpenCV provides several tonemapping methods, including the global tonemapping method and the local tonemapping method.

Implementation of High Dynamic Range Imaging in OpenCV

High Dynamic Range (HDR) imaging in OpenCV involves merging multiple images of the same scene taken with different exposures to create an image with a wider dynamic range.

Here's a code snippet to implement High Dynamic Range Imaging in OpenCV using the exposure fusion method:

  • In this code, we first load two input images using the cv2.imread() function. Then, we create a cv2.MergeMertens object, which is used to merge the input images using the exposure fusion method.
  • Finally, we use the process() method to merge the input images and save the output image using the cv2.imwrite() function. Note that we multiply the output image by 255 to convert it from a float to a uint8 data type, which is the expected data type for image files.
  • This code assumes that the input images are in the same directory as the Python script and have the filenames image1.jpg and image2.jpg.

Input Images:

Input Image 1

input-image1

Input Image 2

input-image1

Fusion Output Image

HDRI-Multi-exposure-output

Conclusion

  • In conclusion, High Dynamic Range (HDR) Imaging is a technique that captures a wider range of brightness levels than traditional imaging methods.
  • It allows us to capture more detail in high-contrast scenes and produce images with greater dynamic range and richer colours. OpenCV provides several methods for HDR imaging, including Mertens HDR, Debevec HDR, and Robertson HDR, each with its advantages and disadvantages.
  • Additionally, OpenCV provides functions for tone mapping HDR images to display them on devices with a lower dynamic range.
  • Overall, HDR imaging has become an important technique in a variety of fields, including photography, computer graphics, virtual reality, and scientific imaging.