HDR format encoding and decoding

Source: Internet
Author: User

HDR stands for high dynamic range, which is a high dynamic range, such as a high dynamic range image (hdri) or a high dynamic range rendering (hdrr ). The dynamic range refers to the relative ratio of the highest signal to the lowest value. Currently, the 16-bit integer format uses the color value from "0" (black) to "1" (white), but the so-called "over range" value is not allowed, for example, the color of the highlights on a metal surface that is whitelist than white.

With the help of HDR, we can use color values beyond the normal range to render more realistic 3D scenes. Perhaps we have all had this experience: driving through a dark tunnel, while the exit is dazzling sunshine, due to the huge contrast of brightness, we may suddenly see a piece of white light around us, and HDR can be used in such a scenario.

The following is a simple example of HDR provided by the openexr website. Openexr is an HDR standard developed by Industrial Light & magic. The industrial magic is a world-famous California studio, which has created many amazing CG and visual effects, such as the total special effects in the 1977 movie star wars.

The leftmost is the original image. The trees are very dark because the overall exposure is affected by the high brightness in the distance. The brightness of the middle image is increased by 3, while that of the right image is increased by 7, tree details are easily identified, and the background is extremely bright.

In short, HDR can be summarized:
The bright area can be very bright, and the dark area can be very dark.
The details of the bright and dark parts are obvious.

Source:
Http://www.graphixer.com.cn/ShowWorks.asp? Type = 3 & from = homepage & id = 20

An image in rgbe format is a compression type of floating point data. Here, RGB specifies the color of the pixel, and E specifies the degree of exposure of the pixel. Different Lighting levels determine the brightness of different pixels. The encoding and decoding methods of rgbe are as follows.

Encoding:

Maxcomponent = max (floatsource. R,
Floatsource. G,
Floatsource. B );
Fexp = Ceil (Ln (maxcomponent)/ln (2 ));
Encoded. r = (unsigned byte) (floatsource. R/power (2, fexp) * 255 );
Encoded. G = (unsigned byte) (floatsource. g/power (2, fexp) * 255 );
Encoded. B = (unsigned byte) (floatsource. B/power (2, fexp) * 255 );
Encoded. E = (unsigned byte) (fexp + 128 );Decoding:

Unsigned char encoded [4];
Fexp = encoded. E-128;
Decoded. r = encoded. R/255 * power (2, fexp );
Decoded. G = encoded. g/255 * power (2, fexp );
Decoded. B = encoded. B/255 * power (2, fexp );

As follows:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.