How to load a HDR image to 3 float R, G, B images?

JIA Pei <[email protected]> Tue, 24 May 2011 18:01:48 -0700
Newsgroups gmane.comp.video.openexr.user,gmane.comp.lib.opencv.user
Message-ID <[email protected]>
--===============3084416926330888249==
Content-Type: multipart/alternative; boundary=001517479328cbb0d904a40f3f98

--001517479328cbb0d904a40f3f98
Content-Type: text/plain; charset=ISO-8859-1

Hi, all:

1) I checked hdrread in Matlab 2010b, which seems to have ignored exposure
time, the code is as follows:

% The formula for transforming (Rm,Gm,Bm,E) into (Rw,Gw,Bw) is given by
> % ((Rm + 0.5) / 256) * 2^(E - 128)
> rgb = ((single(rgbe(:, 1:3)) + 0.5) ./ 256) .* ...
>       repmat(2 .^ (single(rgbe(:,4)) - 128), [1,3]);



2) However, what's suggested on softimage
http://softimage.wiki.softimage.com/index.php/Converting_Radiance_HDR_to_Float_RGB
 is:

> unsigned char hdr_r, hdr_g, hdr_b, hdr_e;
> // -- read hdr_r, hdr_g, hdr_b, hdr_e from the image as unsigned chars.
> // Convert the 8-bit HDR RGBE components to RGB float.
> float r, g, b, e;
>
> e = ldexp( 1.0f, hdr_e - (int)(128+8) );
> r = hdr_r * e;
> g = hdr_g * e;
> b = hdr_b * e;
>
> which seems to be a little bit different from the above. Still, it doesn't
consider the exposure time.


3) What's in FastHDR
http://code.google.com/p/realtimehdrimageprocessing/ considers
exposure time, but it's a bit more different from the above two decoding
methods:

> int ee = javaSignedByteToInt(e) - 128 + 8;
>
>      double f = Math.pow(2, ee) * WHITE_EFFICACY / exposure;
>
>
>>      rgb[0] = (double)(javaSignedByteToInt(r) * f);
>
>      rgb[1] = (double)(javaSignedByteToInt(g) * f);
>
>      rgb[2] = (double)(javaSignedByteToInt(b) * f);
>
>
in which

> javaSignedByteToInt(e) - 128

is just hdr_e because in Java, there is no "unsigned" staff.

Where is a documentation to standardize HDR decoding? Well, all the above 3
methods are more or less similar indeed.


Best Regards

-- 

Pei JIA

Email: [email protected]
cell:    +1 778-318-5816

Welcome to Vision Open
http://www.visionopen.com

--001517479328cbb0d904a40f3f98
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br clear=3D"all"><br><div>Hi, all:</div><div><br></div><div>1)=A0I checked=
 hdrread in Matlab 2010b, which seems to have ignored exposure time, the co=
de is as follows:</div><div><br></div><div><blockquote class=3D"gmail_quote=
" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-l=
eft: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); =
border-left-style: solid; padding-left: 1ex; ">
% The formula for transforming (Rm,Gm,Bm,E) into (Rw,Gw,Bw) is given by<br>=
% ((Rm + 0.5) / 256) * 2^(E - 128)<br>rgb =3D ((single(rgbe(:, 1:3)) + 0.5)=
 ./ 256) .* ...<br>=A0 =A0 =A0 repmat(2 .^ (single(rgbe(:,4)) - 128), [1,3]=
);</blockquote>
<div><br></div><div><br></div><div>2) However, what&#39;s suggested on soft=
image=A0<a href=3D"http://softimage.wiki.softimage.com/index.php/Converting=
_Radiance_HDR_to_Float_RGB">http://softimage.wiki.softimage.com/index.php/C=
onverting_Radiance_HDR_to_Float_RGB</a>=A0is:</div>
<blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-right: 0=
px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-=
left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex=
; ">
<span class=3D"Apple-style-span" style=3D"font-family: Arial, Helvetica, sa=
ns-serif; font-size: 12px; "><pre style=3D"width: 1473px; padding-top: 1em;=
 padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-wid=
th: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-wid=
th: 1px; border-top-style: dashed; border-right-style: dashed; border-botto=
m-style: dashed; border-left-style: dashed; border-top-color: rgb(47, 111, =
171); border-right-color: rgb(47, 111, 171); border-bottom-color: rgb(47, 1=
11, 171); border-left-color: rgb(47, 111, 171); color: black; background-co=
lor: rgb(247, 247, 247); line-height: 1.1em; overflow-x: auto; overflow-y: =
auto; display: block; ">
unsigned char hdr_r, hdr_g, hdr_b, hdr_e;

<font color=3D"green">// -- read hdr_r, hdr_g, hdr_b, hdr_e from the image =
as unsigned chars.</font>

<font color=3D"green">// Convert the 8-bit HDR RGBE components to RGB float=
.</font>
float r, g, b, e;

e =3D ldexp( 1.0f, hdr_e - (int)(128+8) );
r =3D hdr_r * e;
g =3D hdr_g * e;
b =3D hdr_b * e;</pre></span></blockquote><div>which seems to be a little b=
it different from the above. Still, it doesn&#39;t consider the exposure ti=
me.</div><div><br></div><div><br></div><div>3) What&#39;s in FastHDR=A0<a h=
ref=3D"http://code.google.com/p/realtimehdrimageprocessing/">http://code.go=
ogle.com/p/realtimehdrimageprocessing/</a>=A0considers exposure time, but i=
t&#39;s a bit more different from the above two decoding methods:</div>
<blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-right: 0=
px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-=
left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex=
; ">
<blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-right: 0=
px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-=
left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex=
; ">
int ee =3D javaSignedByteToInt(e) - 128 + 8;</blockquote><blockquote class=
=3D"gmail_quote" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom=
: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(2=
04, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span> =A0 =A0<s=
pan class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>double f =3D=
 Math.pow(2, ee) * WHITE_EFFICACY / exposure;</blockquote><blockquote class=
=3D"gmail_quote" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom=
: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(2=
04, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<br></blockquote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px=
; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-wi=
dth: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; =
padding-left: 1ex; ">
<span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span> =A0 =A0<s=
pan class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>rgb[0] =3D (=
double)(javaSignedByteToInt(r) * f);</blockquote><blockquote class=3D"gmail=
_quote" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; ma=
rgin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, =
204); border-left-style: solid; padding-left: 1ex; ">
<span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span> =A0 =A0<s=
pan class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>rgb[1] =3D (=
double)(javaSignedByteToInt(g) * f);</blockquote><blockquote class=3D"gmail=
_quote" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; ma=
rgin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, =
204); border-left-style: solid; padding-left: 1ex; ">
<span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span> =A0 =A0<s=
pan class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>rgb[2] =3D (=
double)(javaSignedByteToInt(b) * f);</blockquote></blockquote><div><br></di=
v><div>in which</div>
<blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-right: 0=
px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-=
left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex=
; ">
javaSignedByteToInt(e) - 128</blockquote><div>is just hdr_e because in Java=
, there is no &quot;unsigned&quot; staff.<br></div><div><br></div><div>Wher=
e is a documentation to standardize HDR decoding? Well, all the above 3 met=
hods are more or less similar indeed.</div>
<div><br></div><div><br></div><div>Best Regards</div><div><br></div><div>--=
 <br><div><br></div><div>Pei JIA</div><div><br></div><div>Email: <a href=3D=
"mailto:[email protected]" target=3D"_blank">[email protected]</a></div><di=
v>
cell: =A0 =A0+1 778-318-5816</div><div><br></div>Welcome to Vision Open<br>=
<a href=3D"http://www.visionopen.com" target=3D"_blank">http://www.visionop=
en.com</a><br>
</div></div>

--001517479328cbb0d904a40f3f98--


--===============3084416926330888249==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Openexr-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/openexr-user

--===============3084416926330888249==--