how we can amplify an image with nearest neighbour interpolation

 Accepted Answer

Amplify?? you mean resize? if that's what you mean here is the code
IResized= imresize(I,scale,'nearest');

6 Comments

Get rid of 'nearest' - that will just take the nearest value instead of using bicubic interpolation of nearest neighbors.
But he wants to have nearest neighbor interpolation.
Nearest neighbor interpolation means that if the output pixel lands in between the input pixels, you will interpolate. Say if you were using bilinear interpolation and you had a pixel at column 42 with value 100 and a pixel at column 43 with value 200. Now let's say you were resizing or resampling the image and you needed to get the value of the image at column 42.75. That's 3/4 (75%) of the way from 42 to 43, so the output pixel would have a value of 175, which is 3/4 of the way from 100 to 200. If you use the 'nearest' option, it will say that the pixel at 43 is closest to the pixel needed at 42.75, so it would just take that value - a value of 200 - because it's the nearest. So no interpolation takes place in that case. This option is there because it's the fastest - no interpolation needed - but it's not the most accurate.
I understand what is nearest neighbor interpolation and what is bilinear interpolation
1) it is a C0 interpolation and as you perfectly described, it just takes the value of the closest point. Although it might sound strange, but that is still type of interpolation and it is known as C0 interpolation.
2) (s)he wants to do nearest neighbor interpolation, (read his/her question). I don't know why that is the method being requested, but nearest neighbor is the method requested in the question.
If it was atmospheric data, I could imagine why using nearest neighbor interpolation. Also in processing spectral images (in remote sensing) we often prefer nearest neighbor interpolation because those numbers are measurements and we don't want to mess up the measurements.
So I don't know why (s)he asked for that method. But I am guessing there is a reason for it. Nearest neighbor doesn't necessary gives an smooth surface anyway.
OK, that's fine. I agree with everything you said. I've never heard of "C0 Interpolation" but if that's standard terminology in some sub-field of image processing, that's fine.
Actually I made a mistake it is C-1. It is one order lower than the polynomial being used. It means continuity. C0 means the curves touches at the boundary( Which in nearest neighbor clearly doesn't). C1 means the first derivative is also continuous and so on.
Go down to parametric continuity.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!