Interpolate using a different method without the original image

1 ビュー (過去 30 日間)
ryan 2022 年 5 月 20 日
コメント済み: ryan 2022 年 5 月 20 日
The original image was resampled using linear interpolation. I now want to resample the original image using nearest neighbor interpolation. However, I don't have the original image anymore. Is there a way I could use the linearily interpolated image to produce a nearest neighbor image? The dimensions of the linearily interpolated image and nearest neighbor image would be the same; I just want the pixel values to change as if the original image were interpolated using nearest neighbor.
Thanks in advance for any help!

回答 (1 件)

John D'Errico
John D'Errico 2022 年 5 月 20 日
編集済み: John D'Errico 2022 年 5 月 20 日
Um, no, or, yes. Anyway, you cannot do it directly. And it may be completely impossible to do. All of that depends on several things you have not told us.
First, when you say that "linear" interpolation was done, you have not provided sufficient information, as there are at least three different ways to perform linear interpolation on a regular lattice. (There are surely others that could be nominally called linear interpolation I could think of if you gave me some time, but these would be the common choices.) Until you say which was done, there is no hope to proceed at all, as that would be provably impossible. The 3 distinct ways I can think of off the top of my head are:
  1. Tensor product linear interpolation, sometimes known as bilinear interpolation. (Arguably, this is not truly linear in some respects, but everyone calls it that. I would be splitting hairs to get into the subtleties.)
  2. Split each square in the lattice into two triangles, where the shared diagonal is oriented along a line parallel to y=x. Once that has been done, now purely linear interpolation is possible inside each triangle.
  3. Split each square in the lattice into two triangles, where the shared diagonal is oriented along a line parallel to y=-x. Once that has been done, now purely linear interpolation is possible inside each triangle.
As you can see, the dissection derived from 2 and 3 are similar in theory, but clearly will result in different interpolants. You can see the two dissections below.
V = [0 0;1 0;0 1;1 1];
T2 = [1 2 4;1 3 4];
T3 = [1 2 3;2 3 4];
title('Method 2 dissection')
title('Method 3 dissection')
Once the actual interpolation method is known, now you have a chance of solving the problem. You simply form the inverse operation, using the interpolated values to infer the original image. This would be equivalent to solving a linear system of equations in the unknown image elements of the original image. Once you have recovered the original image, now going forward is trivial, since you can use any method of interpolation your heart desires to go forwards.
HOWEVER, if the interpolated image was interpolated on a more coarse grid than the original, then you cannot perform the inverse operation. It is now impossible to solve this problem, as the linear system you need to solve will be under-determined. So it is only possible if the original interpolation resulted in a finer grid, and then you could reverse that operation.
Your question seems to be, can you solve this problem directly, without going through the inverse operation? Well, yes. In theory you can, since nearest neighbor is a pretty simple operation, but it would still require the inverse transformation. And that means it is not worth the bother, since nearest neighbor is just so simple and efficient to write.
  1 件のコメント
ryan 2022 年 5 月 20 日
Sorry for not providing enough information - I didn't realize there were different methods of linear interpolation. Based on your explanation, I think the linear interpolation method that was used was Method 1. To my knowledge, the interp3 function was used to conduct the first interpolation. What would be the inverse operation for the interp3 function? Or does this fit into the category of a more course grid that you mentioned would be impossible?
Thank you for your detailed response!


Community Treasure Hunt

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

Start Hunting!

Translated by