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.

  • Sana: hi steve, could you explain to me how i would be able to use the dir function, to do a loop through a directory...
  • Nishtha: Sir, I have preprocessed the image in following steps: [1] adaptive histogram equalization [2] thresholding...
  • Kristof: I also strongly support the idea. I have just recently bumped into the problem that im2single was not...
  • Steve: David—I’ m glad you found it useful!
  • David Lalejini: I found your example very useful for finding connected nodes in a large set of input pairs. I start...
  • tommy: Dear Steve, I have a question,please if you are kind to help me regarding the accumulator array dimensions of...
  • Steve: Abc—I don’t know how to distinguish the faces. You might try posting your question in the MATLAB...
  • Manju: well if we have a few ovals within each other like in a cell how do we measure the distance from the center...
  • Steve: Manju—What do you mean? How is each region defined?
  • Manju: if we have 2-3 regions within each other how do we measure the regions of each one?

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