Steve on Image Processing

May 12th, 2006

Spatial transformations: Where is the output image?

I wrote previously that most spatial image transformation implementations use inverse mapping. The Image Processing Toolbox function imtransform is implementated using this technique.

Here's an interesting issue that arose during the design of imtransform: How does it know where the output image is located in the x-y plane? In other words, in the inverse mapping diagram below, how does it know exactly where the output grid should be?

There are three basic problems you can have with the output grid. It can be too small; it can be too big; or it can be in the wrong place entirely. I'll illustrate these situations with an output grid that is the same size as the input grid, and that is also in the same place.

In the first example, the spatial transformation magnifies the input image. The output grid doesn't cover enough territory in output space to capture the entire transformed image.

In the next example, the spatial transformation shrinks the input image. As a result, the output grid covers too much territory. The black output pixels below are output image pixels that aren't needed to capture the entire transformed image.

In the final example, the spatial transformation moves the input somewhere else. Maybe the transformation is simply a 1000-pixel horizontal translation. In this situation, the output grid doesn't contain any of the transformed image!

When we were designing imtransform, we thought that any of these scenarios would likely result in frustrated users calling tech support. We tried to avoid this by making imtransform do "the right thing."

Next time, I'll describe the calculation imtransform does to automatically produce the results expected by users. (Almost all the time, that is.) If you want a preview, take a look at the function findbounds.

7 Responses to “Spatial transformations: Where is the output image?”

  1. Tien replied on :

    Hi Steve,

    I don’t have any question regarding your post above but I am wondering if you could give some suggestions/advice on problems I am facing in image processing.

    I have numerous images containing some objects. I have been trying to do image segmentation in Matlab ie., to extract the object of interest but so far can only get parts and parts of it (not as a whole object). The rest of the object is more or less transparent and hence couldn’t be detected. Can you tell me if there is any way to obtain a whole object from a few disconnected parts of it?

    Thanks a lot for your help

    Best regards,

    Tien

  2. Steve replied on :

    Tien - send me a sample image.

  3. Tien replied on :

    Hi Steve,

    I can’t find your email address here. Can you tell me how to send you the sample image?

    Tien

  4. Steve replied on :

    Tien - my name at the upper right corner has a mailto link. The address is eddins@mathworks.com.

  5. Tien replied on :

    Hi Steve,

    I sent a couple of sample images to your email account last week (June 7th). I just want to confirm that you’ve received them.

    BTW, I don’t expect you to solve the problem for me. All I’d like to ask for is some direction/ideas to work on.

    Thanks in advance,

    Tien

  6. Mahsa replied on :

    Hi Steve,

    I want to align two images , I have pose parameters , T1 ,T2,S,teta, as respectivly transform ,scaling and rotation . But I have third promblem you mention in your post , how can I solve my problem?

    Thanks,Cheers,
    M.

  7. Steve replied on :

    Mahsa—Take a look at my other spatial transformation blogs, especially the ones about translation and controlling the output grid.

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.