Smooth interpolation for warping an image using a deformation map
조회 수: 12 (최근 30일)
이전 댓글 표시
I have a series of 2D images that I need to register similar to the one below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/208231/image.png)
The registration is neither geometric nor rigid, but defined by a displacement map. I derive the displacement map by computing the gradient of a spatial registration error map (called “errorMap” below).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/208232/image.png)
I know that errorMap is correct and exactly describes the spatial registration error. I use errorMap to compute the deformation map by computing its gradient.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/208233/image.png)
Then I apply this deformation map to the reference image using imwarp. The code is:
[uy, ux] = gradient(errorMap);
D = cat(3, uy, yx);
B = imwarp(im, D, 'linear');
The problem I’m running into is that, when I apply the displacement map to the image, I get, well, this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/208234/image.png)
I feel like it’s moving the pixels from the reference image into the source image rather than interpolating smoothly, leaving very conspicuous discontinuities at the edges. This is regardless of the interpolation method I apply. I tried applying the deformation map in steps of 1/10 to try to "nudge" it towards the final registration:
B2 = imwarp(im, D./10, 'linear');
for idx = 1:9
B2 = imwarp(B2, D./10, 'linear');
end
While this removes some of the discontinuities, it also leaves what seem to be blotchy smoothing artifacts:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/208235/image.png)
It makes no difference whether I use a linear or a cubic interpolation. Using a nearest neighbor interpolation doesn't work well at all, especially if I "nudge" the deformation by very small amounts (essentially, no deformation is applied in this case).
How can I apply this deformation map in a smooth manner, and with sub-pixel accuracy? What options are available in Matlab and the image processing toolbox? Is there an alternative to imwarp that would do a better job of applying this deformation map?
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!