Steve on Image Processing

October 5th, 2007

HDR and tone mapping links

In photography and color science, MathWorks developer Jeff Mather's personal interests intersect with his work. He guest-blogged here last year with a post about the CIE Standard Observer. Earlier this month, he posted on his personal blog about high dynamic range (HDR) imaging and associated tone mapping algorithms. If you want to know more about these topics, and the related new features in the Image Processing Toolbox, I encourage you to take a look:

8 Responses to “HDR and tone mapping links”

  1. Pia replied on :

    I have a couple of questions regarding the size and techniques using the imagesc function. I would like to know first of all the actual size of the resulting image, for instance if my original image has 240 rows times 24000 columns, will it be reduced to fit the imagesc default size? And if so, how does Matlab do it? Which points does it take away and which will it keep?
    I have looked for a while but I have not been able to find any answers, I hope it isn´t such stupid question.
    Thank you very much for your time.

  2. Steve replied on :

    Pia—imagesc simply scales the image to fit into the current axes. If there’s no figure currently open, a figure gets created at the default size, and the image gets plotted into an axes inside that figure, also at the default size. Nearest-neighbor interpolation is used. If you want more scaling control, try using the Image Processing Toolbox function imtool.

  3. Pia replied on :

    Thank you for your help and for responding so quickly.

    If I may, I have another question: I am making a ‘custom’ 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 ‘atan2′ for input arguments of type ’struct’.

    Error in ==> cart2pol at 22
    th = atan2(y,x);

    Error in ==> maketform>inv_composite at 584
    U = feval(t.tdata(i).inverse_fcn, U, t.tdata(i));

    Error in ==> images\private\tform at 56
    X = feval( t.(f.fwd_fcn), U, t );

    Error in ==> tforminv at 68
    varargout = tform(’inv’, nargout, varargin{:});

    Error in ==> tformarray at 241
    M = tforminv(G,T);

    Error in ==> imtransform at 273
    B = tformarray(args.A, args.tform, args.resampler, tdims_a, tdims_b, …

    Error in ==> rphi2xy_imtransf at 76
    Z = imtransform(absd_chiqui,TFORM, ‘UData’,udata,’VData’,vdata,’XData’,xdata,’YData’,ydata);

    My code is like this:
    dims_IN = 2;
    dims_OUT = 2;
    FRWD_FCN = @pol2cart;
    INV_FCN = @cart2pol;
    TDATA = [];
    TFORM = maketform(’custom’,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, ‘UData’,udata,’VData’,vdata,’XData’,xdata,’YData’,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

  4. Steve replied on :

    Pia—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’t expect, and why. You might try first to see if you can get your custom tform struct to work with tforminv. If that doesn’t work, there’s no way imtransform can use it.

  5. Pia replied on :

    Thank you very much, I will try what you propose.

  6. John DiCecco replied on :

    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:

    >> I = imread(’cameraman.tif’);
    tform = maketform(’affine’,[1 0 0; .5 1 0; 0 0 1]);
    J = imtransform(I,tform);
    imshow(I), figure, imshow(J)
    ??? Error using ==> imtransform>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 ==> 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

  7. Steve replied on :

    John—That’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’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’t you send me your version and platform information, and I’ll follow up with you further by e-mail.

  8. Steve replied on :

    John and I worked out his problem via e-mail. It turned out to be extraneous functions on his path.

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Steve Eddins manages the Image & Geospatial development team at The MathWorks and coauthored Digital Image Processing Using MATLAB. He writes here about image processing concepts, algorithm implementations, and MATLAB.

  • Steve: Kezia—Try imrotate.
  • kezia: steve, how to perform rotation of structuring element by 15 degrees. kindly answer my question. thank u kezia...
  • Steve: Tasha—I only accept comments that are relevant to the particular blog post or are questions or comments...
  • Tasha: Steve,I send you a comment here but still didn’t get any reply yet.I did not see my comment posted here...
  • Steve: Carsten—Thanks for your input.
  • Carsten: Another vote for either imtranslate.m, or at least a blurb in the imtransform help why pure translation...
  • Loren Shure: If you look towards the end of the fftfilt program, you will see that there’s a check to see if...
  • Steve: Sonja—My imwritesize submission on the MATLAB Central File Exchange might be helpful. It was posted...
  • Steve: Grant—Sorry, but it won’t be for R2010a. That development deadline has already passed.
  • Sonja: My publisher is wanting images for a new book to be 300 dpi. Only 5 of the 19 images are 300, the rest are...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.