Main Content

tonemap

Render high dynamic range image for viewing

Description

RGB = tonemap(HDR) converts the high dynamic range image HDR to a lower dynamic range image, RGB, suitable for display, using a process called tone mapping. Tone mapping is a technique used to approximate the appearance of high dynamic range images on a display with a more limited dynamic range.

RGB = tonemap(HDR,Name=Value) uses name-value arguments to control various aspects of the tone mapping.

example

Examples

collapse all

This example shows how to display a high dynamic range (HDR) image. To view an HDR image, you must first convert the data to a dynamic range that can be displayed correctly on a computer.

Read a high dynamic range (HDR) image using hdrread. If you try to display the HDR image, notice that it does not display correctly.

hdr_image = hdrread("office.hdr");
imshow(hdr_image)

Figure contains an axes object. The hidden axes object contains an object of type image.

Convert the HDR image to a dynamic range that can be viewed on a computer, using the tonemap function. This function converts the HDR image into an RGB image of data type uint8.

rgb = tonemap(hdr_image);
whos
  Name             Size                  Bytes  Class     Attributes

  hdr_image      665x1000x3            7980000  single              
  rgb            665x1000x3            1995000  uint8               

Display the RGB image.

imshow(rgb)

Figure contains an axes object. The hidden axes object contains an object of type image.

Input Arguments

collapse all

High dynamic range image, specified as an m-by-n-by-3 array of nonnegative numbers.

Data Types: single | double

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: RGB = tonemap(HDR,AdjustLightness=[0.05 0.95]) adjusts the lightness of the rendered image such that pixel values between 0.05 and 0.95 linearly map to display values between 0 and 1.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: RGB = tonemap(HDR,"AdjustLightness",[0.05 0.95])

Overall lightness of the rendered image, specified as a two-element vector. The vector takes the form [low high], where low and high are luminance values of the low dynamic range image, in the range (0, 1]. These values are passed to imadjust.

Data Types: double

Saturation of colors in the rendered image, specified as a positive scalar. When the value is greater than 1, the colors are more saturated. When the value is in the range (0, 1], colors are less saturated.

Data Types: double

Number of tiles used during the adaptive histogram equalization part of the tone mapping operation, specified as a 2-element vector of positive integers. The vector takes the form [rows cols], where rows and cols specify the number of rows and columns of tiles. Both rows and cols must be at least 2. The total number of image tiles is equal to rows*cols. A larger number of tiles results in an image with greater local contrast.

Data Types: double

Output Arguments

collapse all

Low dynamic range image, returned as an m-by-n-by-3 array.

Data Types: uint8

Version History

Introduced in R2007b