Steve on Image Processing

June 29th, 2006

Multidimensional interpolation with integer input

A customer asked me last week how to do multidimensional interpolation with integer inputs. The MATLAB function interpn supports only double- and single-precision inputs.

It's possible to do this using a little-known Image Processing Toolbox function called tformarray. But tformarray is a general spatial transformation engine with a complicated syntax. It isn't easy to figure out how to use it for interpolation, so I decided to write a wrapper M-file to do it.

The function iminterpn, which has a syntax similar to interpn, is now available on the MATLAB Central File Exchange. I hope some of you find it useful.

6 Responses to “Multidimensional interpolation with integer input”

  1. tr replied on :

    thank u sir

  2. Damodar replied on :

    Hi Steve:

    i have a gray value image(512×512), it has some high contrast objects in it. i extracted the high contrast objects from the gray value image and created another binary image of same size. now, i want to do interpolation on the gray value image where/under the high contrast objects are, and i also want to overlay the high contrast objects image on the interploated new image. could you please help me in this step?

    Thank U.
    Sincerely
    Damodar

  3. Steve replied on :

    Damodar—You might find the function roifill to be useful for interpolating in the gray value image based on the locations of the high contrast objects. I’m not I understand your second question. If you overlay the high-contrast objects over the original image, which has been changed only by modifying the pixels where the high-contrast objects are, wouldn’t you expect the result to look just like the original image?

  4. reji A p replied on :

    Sir

    thank you very much for giving information for my last question.sir now I want to upsample the image using cubic spline interpolation.sir I used the following code [X,Y]=meshgrid(2:2:256)
    Z(X,Y)=Image
    [X1,Y1]=meshgrid(2:1:256)

    Z1 = interp2(X,Y,Z,X1,Y1,’spline’)

    I got the error” Subscripted assignment dimension mismatch”.

    Can I use ‘interp2′ instruction for cubic spline interpolation of image(both colour and grey)
    reji

  5. reji A p replied on :

    hai
    I want to upsample the image using cubic spline interpolation.
    Can I use ‘interp2′ instruction for cubic spline interpolation of image(both colour and grey)
    Can I use convolution methods for cubic spline interpolation
    ‘Pratt’ in his image processing book mentioned that convolution kernals can be used for interpolation.
    reji

  6. Steve replied on :

    Reji—Yes, you can use interp2 for cubic spline interpolation of an image. I do not know why you received an error message. You’ll need to check your interp2 inputs carefully against the description in the reference page for interp2.

    Continuous-time convolution kernels can be used for interpolation. For example, linear interpolation can be viewed as convolution of an impulse train with a triangular kernel. However, cubic spline interpolation is more involved, because the proper kernel weights are data-dependent.

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.