<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: HDR and tone mapping links</title>
	<atom:link href="http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/</link>
	<description>Steve Eddins manages the Image &#38; Geospatial development team at The MathWorks and coauthored Digital Image Processing Using MATLAB. He writes here about image processing concepts, algorithm implementations, and MATLAB.</description>
	<lastBuildDate>Sat, 11 Feb 2012 18:27:50 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Jeff Mather</title>
		<link>http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-24150</link>
		<dc:creator>Jeff Mather</dc:creator>
		<pubDate>Fri, 29 Apr 2011 14:04:28 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-24150</guid>
		<description>Simon,

Thanks for pointing out a bug in HDRREAD.  The .hdr format (which uses RGBE encoding) has a special condition when all of the samples for one pixel are less than 10E-38; those pixels should get mapped to (0,0,0,0), and they do in HDRWRITE.  But I neglected to put similar code in HDRREAD to convert (0,0,0,0) to (0,0,0) as the spec requires.

I will try my best to get that fix into the next version of the Image Processing Toolbox, with a workaround available even sooner.

BTW, I think you might notice that the values of t are quite a bit smaller than 0.5740.  When I run the code I see 0.5740E-41.

Jeff</description>
		<content:encoded><![CDATA[<p>Simon,</p>
<p>Thanks for pointing out a bug in HDRREAD.  The .hdr format (which uses RGBE encoding) has a special condition when all of the samples for one pixel are less than 10E-38; those pixels should get mapped to (0,0,0,0), and they do in HDRWRITE.  But I neglected to put similar code in HDRREAD to convert (0,0,0,0) to (0,0,0) as the spec requires.</p>
<p>I will try my best to get that fix into the next version of the Image Processing Toolbox, with a workaround available even sooner.</p>
<p>BTW, I think you might notice that the values of t are quite a bit smaller than 0.5740.  When I run the code I see 0.5740E-41.</p>
<p>Jeff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon  Silk</title>
		<link>http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-23870</link>
		<dc:creator>Simon  Silk</dc:creator>
		<pubDate>Mon, 24 Jan 2011 19:47:46 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-23870</guid>
		<description>Hi Steve and others,

I&#039;ve been experimenting with some HDR algorithms, and I wanted to now use the .hdr file format to pass some intermediate results from MATLAB to some C++ code I have. 

However, I&#039;m finding some weird rounding errors when writing/ reading hdr images with MATLAB, even just writing them out then reading them back in. Specifically, very small values get rounded to zero when I write them to then read them back from an hdr file. More generally, why are values changing a lot when doing this? Does the hdr format require some re-scaling or rounding of values?

Here&#039;s a simple example. 

&lt;pre&gt;
q=zeros(10,10,3);
q(:,:,:)=0;
hdrwrite(q,&#039;test.hdr&#039;);
t=hdrread(&#039;test.hdr&#039;)
&lt;/pre&gt;

When I run this code, all the entries for t are 0.5740. With actual images, what I&#039;ll tend to see is a number like 3.042e-5 turn into a zero. The result is that in the HDR weighting matrix sum, the smallest numbers (which would give the biggest final composite values since) turn to zeros resulting in NANs in the final HDR image, so the total dynamic range is much smaller than it should be.

Thanks.</description>
		<content:encoded><![CDATA[<p>Hi Steve and others,</p>
<p>I&#8217;ve been experimenting with some HDR algorithms, and I wanted to now use the .hdr file format to pass some intermediate results from MATLAB to some C++ code I have. </p>
<p>However, I&#8217;m finding some weird rounding errors when writing/ reading hdr images with MATLAB, even just writing them out then reading them back in. Specifically, very small values get rounded to zero when I write them to then read them back from an hdr file. More generally, why are values changing a lot when doing this? Does the hdr format require some re-scaling or rounding of values?</p>
<p>Here&#8217;s a simple example. </p>
<pre>
q=zeros(10,10,3);
q(:,:,:)=0;
hdrwrite(q,'test.hdr');
t=hdrread('test.hdr')
</pre>
<p>When I run this code, all the entries for t are 0.5740. With actual images, what I&#8217;ll tend to see is a number like 3.042e-5 turn into a zero. The result is that in the HDR weighting matrix sum, the smallest numbers (which would give the biggest final composite values since) turn to zeros resulting in NANs in the final HDR image, so the total dynamic range is much smaller than it should be.</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Mather</title>
		<link>http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-23326</link>
		<dc:creator>Jeff Mather</dc:creator>
		<pubDate>Thu, 29 Jul 2010 17:11:37 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-23326</guid>
		<description>Hi Simon,

The MAKEHDR function doesn&#039;t currently take camera response curves into account at all.  Consequently, there&#039;s nothing to save for later use.  (I know, it&#039;s a rather naïve approach.)

You might be interested in this article from Peter Web that shows another method of HDR generation using MATLAB: http://www.mathworks.com/company/newsletters/digest/2008/july/hdri.html  He does compute camera response curves, which could be useful to your work.</description>
		<content:encoded><![CDATA[<p>Hi Simon,</p>
<p>The MAKEHDR function doesn&#8217;t currently take camera response curves into account at all.  Consequently, there&#8217;s nothing to save for later use.  (I know, it&#8217;s a rather naïve approach.)</p>
<p>You might be interested in this article from Peter Web that shows another method of HDR generation using MATLAB: <a href="http://www.mathworks.com/company/newsletters/digest/2008/july/hdri.html" rel="nofollow">http://www.mathworks.com/company/newsletters/digest/2008/july/hdri.html</a>  He does compute camera response curves, which could be useful to your work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon Silk</title>
		<link>http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-23325</link>
		<dc:creator>Simon Silk</dc:creator>
		<pubDate>Thu, 29 Jul 2010 16:40:11 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-23325</guid>
		<description>Hi Steve,

I am currently doing masters research related to High Dynamic Range Imaging. In particular, I am working on ghost removal. This usually requires being able to apply the camera response curve in different manners in different parts of the image. 

Can you recommend a way to get the camera response curve and save it so it can be used manually later and applied to various parts of the image? 

I don&#039;t see this functionality currently in the Matlab IP toolbox&#039;s HDR functions, but it seems like an obvious thing to want. Thanks.</description>
		<content:encoded><![CDATA[<p>Hi Steve,</p>
<p>I am currently doing masters research related to High Dynamic Range Imaging. In particular, I am working on ghost removal. This usually requires being able to apply the camera response curve in different manners in different parts of the image. </p>
<p>Can you recommend a way to get the camera response curve and save it so it can be used manually later and applied to various parts of the image? </p>
<p>I don&#8217;t see this functionality currently in the Matlab IP toolbox&#8217;s HDR functions, but it seems like an obvious thing to want. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-12814</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Fri, 26 Oct 2007 21:02:08 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-12814</guid>
		<description>John and I worked out his problem via e-mail.  It turned out to be extraneous functions on his path.</description>
		<content:encoded><![CDATA[<p>John and I worked out his problem via e-mail.  It turned out to be extraneous functions on his path.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-12695</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Wed, 24 Oct 2007 19:50:12 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-12695</guid>
		<description>John&#8212;That&#039;s a puzzle.  Normally, you might get this error message when using a tform struct containing only an inverse mapping and no forward mapping.  In that case, imtransform uses an iterative optimization procedure to try to find the output spatial bounds, and sometimes that procedure can fail to find a solution.  But that shouldn&#039;t happen for affine, for which it is easy to compute both the forward and the inverse mapping.  I can run the example OK using R2007b on Windows.  Why don&#039;t you send me your version and platform information, and I&#039;ll follow up with you further by e-mail.</description>
		<content:encoded><![CDATA[<p>John&mdash;That&#8217;s a puzzle.  Normally, you might get this error message when using a tform struct containing only an inverse mapping and no forward mapping.  In that case, imtransform uses an iterative optimization procedure to try to find the output spatial bounds, and sometimes that procedure can fail to find a solution.  But that shouldn&#8217;t happen for affine, for which it is easy to compute both the forward and the inverse mapping.  I can run the example OK using R2007b on Windows.  Why don&#8217;t you send me your version and platform information, and I&#8217;ll follow up with you further by e-mail.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John DiCecco</title>
		<link>http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-12694</link>
		<dc:creator>John DiCecco</dc:creator>
		<pubDate>Wed, 24 Oct 2007 19:23:09 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-12694</guid>
		<description>This is an unrelated question but concerns the image processing toolbox.  I am using a site license for the Naval Undersea Warfare Center in Newport RI.  I am trying to do some generic affine transformations but keep getting errors.  So I went to the help section for imtransform and copied and pasted the code that was there as an example and still get the same error:

&gt;&gt; I = imread(&#039;cameraman.tif&#039;);
tform = maketform(&#039;affine&#039;,[1 0 0; .5 1 0; 0 0 1]);
J = imtransform(I,tform);
imshow(I), figure, imshow(J)
??? Error using ==&gt; imtransform&gt;parse_inputs at 440
XData and YData could not be automatically determined.Try specifying XData and YData explicitly in the call to IMTRANSFORM.

Error in ==&gt; imtransform at 262
args = parse_inputs(varargin{:});

Now of course I can enter xdata and ydata to map the old image to the new one but why am I getting this error on an example?

Thanks,
John</description>
		<content:encoded><![CDATA[<p>This is an unrelated question but concerns the image processing toolbox.  I am using a site license for the Naval Undersea Warfare Center in Newport RI.  I am trying to do some generic affine transformations but keep getting errors.  So I went to the help section for imtransform and copied and pasted the code that was there as an example and still get the same error:</p>
<p>&gt;&gt; I = imread(&#8216;cameraman.tif&#8217;);<br />
tform = maketform(&#8216;affine&#8217;,[1 0 0; .5 1 0; 0 0 1]);<br />
J = imtransform(I,tform);<br />
imshow(I), figure, imshow(J)<br />
??? Error using ==&gt; imtransform&gt;parse_inputs at 440<br />
XData and YData could not be automatically determined.Try specifying XData and YData explicitly in the call to IMTRANSFORM.</p>
<p>Error in ==&gt; imtransform at 262<br />
args = parse_inputs(varargin{:});</p>
<p>Now of course I can enter xdata and ydata to map the old image to the new one but why am I getting this error on an example?</p>
<p>Thanks,<br />
John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pia</title>
		<link>http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-11619</link>
		<dc:creator>Pia</dc:creator>
		<pubDate>Wed, 10 Oct 2007 14:05:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-11619</guid>
		<description>Thank you very much, I will try what you propose.</description>
		<content:encoded><![CDATA[<p>Thank you very much, I will try what you propose.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-11615</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Wed, 10 Oct 2007 13:05:35 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-11615</guid>
		<description>Pia&#8212;It looks to me like you have an ordinary debugging problem to solve.  Your error message is telling you that a struct value, instead of a numeric value, is being passed into cart2pol.  Set a breakpoint - dbstop if error - run the code, and then look up and down the function call stack to see if you can understand which variables contain values you don&#039;t expect, and why.  You might try first to see if you can get your custom tform struct to work with &lt;tt&gt;tforminv&lt;/tt&gt;.  If that doesn&#039;t work, there&#039;s no way &lt;tt&gt;imtransform&lt;/tt&gt; can use it.</description>
		<content:encoded><![CDATA[<p>Pia&mdash;It looks to me like you have an ordinary debugging problem to solve.  Your error message is telling you that a struct value, instead of a numeric value, is being passed into cart2pol.  Set a breakpoint &#8211; dbstop if error &#8211; run the code, and then look up and down the function call stack to see if you can understand which variables contain values you don&#8217;t expect, and why.  You might try first to see if you can get your custom tform struct to work with <tt>tforminv</tt>.  If that doesn&#8217;t work, there&#8217;s no way <tt>imtransform</tt> can use it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pia</title>
		<link>http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-11611</link>
		<dc:creator>Pia</dc:creator>
		<pubDate>Wed, 10 Oct 2007 09:00:04 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2007/10/05/hdr-and-tone-mapping-links/#comment-11611</guid>
		<description>Thank you for your help and for responding so quickly.

If I may, I have another question: I am making a &#039;custom&#039; spatial transformation and I am using pol2cart and cart2pol as the forward and inverse functions. I get the following error message:

??? Undefined function or method &#039;atan2&#039; for input arguments of type &#039;struct&#039;.

Error in ==&gt; cart2pol at 22
th = atan2(y,x);

Error in ==&gt; maketform&gt;inv_composite at 584
    U = feval(t.tdata(i).inverse_fcn, U, t.tdata(i));

Error in ==&gt; images\private\tform at 56
X = feval( t.(f.fwd_fcn), U, t );

Error in ==&gt; tforminv at 68
varargout = tform(&#039;inv&#039;, nargout, varargin{:});

Error in ==&gt; tformarray at 241
            M = tforminv(G,T);

Error in ==&gt; imtransform at 273
B = tformarray(args.A, args.tform, args.resampler, tdims_a, tdims_b, ...

Error in ==&gt; rphi2xy_imtransf at 76
Z = imtransform(absd_chiqui,TFORM, &#039;UData&#039;,udata,&#039;VData&#039;,vdata,&#039;XData&#039;,xdata,&#039;YData&#039;,ydata);

My code is like this:
dims_IN = 2;
dims_OUT = 2; 
FRWD_FCN = @pol2cart;
INV_FCN = @cart2pol;
TDATA = [];
TFORM = maketform(&#039;custom&#039;,dims_IN, dims_OUT, FRWD_FCN,INV_FCN,TDATA);
udata = [range_start range_end];
vdata = [-angle_w/2 angle_w/2];
xdata = [range_start range_end];
ydata = [range_end*sin(angle_w/2) -range_end*sin(angle_w/2)];
Z = imtransform(absd_chiqui,TFORM, &#039;UData&#039;,udata,&#039;VData&#039;,vdata,&#039;XData&#039;,xdata,&#039;YData&#039;,ydata);

Initially I did not write any UData, VDAta, XData or YData and I got this error message:
XData and YData could not be automatically determined.Try specifying XData and YData explicitly in the call to IMTRANSFORM.

So I guess my question is: isn´t it possible to use such functions for a custom transformation, or is my problem in the TFORM definition?

Thank you again for your time,

Pia</description>
		<content:encoded><![CDATA[<p>Thank you for your help and for responding so quickly.</p>
<p>If I may, I have another question: I am making a &#8216;custom&#8217; spatial transformation and I am using pol2cart and cart2pol as the forward and inverse functions. I get the following error message:</p>
<p>??? Undefined function or method &#8216;atan2&#8242; for input arguments of type &#8216;struct&#8217;.</p>
<p>Error in ==&gt; cart2pol at 22<br />
th = atan2(y,x);</p>
<p>Error in ==&gt; maketform&gt;inv_composite at 584<br />
    U = feval(t.tdata(i).inverse_fcn, U, t.tdata(i));</p>
<p>Error in ==&gt; images\private\tform at 56<br />
X = feval( t.(f.fwd_fcn), U, t );</p>
<p>Error in ==&gt; tforminv at 68<br />
varargout = tform(&#8216;inv&#8217;, nargout, varargin{:});</p>
<p>Error in ==&gt; tformarray at 241<br />
            M = tforminv(G,T);</p>
<p>Error in ==&gt; imtransform at 273<br />
B = tformarray(args.A, args.tform, args.resampler, tdims_a, tdims_b, &#8230;</p>
<p>Error in ==&gt; rphi2xy_imtransf at 76<br />
Z = imtransform(absd_chiqui,TFORM, &#8216;UData&#8217;,udata,&#8217;VData&#8217;,vdata,&#8217;XData&#8217;,xdata,&#8217;YData&#8217;,ydata);</p>
<p>My code is like this:<br />
dims_IN = 2;<br />
dims_OUT = 2;<br />
FRWD_FCN = @pol2cart;<br />
INV_FCN = @cart2pol;<br />
TDATA = [];<br />
TFORM = maketform(&#8216;custom&#8217;,dims_IN, dims_OUT, FRWD_FCN,INV_FCN,TDATA);<br />
udata = [range_start range_end];<br />
vdata = [-angle_w/2 angle_w/2];<br />
xdata = [range_start range_end];<br />
ydata = [range_end*sin(angle_w/2) -range_end*sin(angle_w/2)];<br />
Z = imtransform(absd_chiqui,TFORM, &#8216;UData&#8217;,udata,&#8217;VData&#8217;,vdata,&#8217;XData&#8217;,xdata,&#8217;YData&#8217;,ydata);</p>
<p>Initially I did not write any UData, VDAta, XData or YData and I got this error message:<br />
XData and YData could not be automatically determined.Try specifying XData and YData explicitly in the call to IMTRANSFORM.</p>
<p>So I guess my question is: isn´t it possible to use such functions for a custom transformation, or is my problem in the TFORM definition?</p>
<p>Thank you again for your time,</p>
<p>Pia</p>
]]></content:encoded>
	</item>
</channel>
</rss>

