如何在图像的旋转部分用原始图像的背景填充黑色?请注意,只有非常小的位移才能剪切图像。原始图像和变形图像的大小相同。如何用原始图像的背景填充图像的旋转部分中的黑色?
这是我试过的。任何人都可以提出更好的方法?的MATLAB代码和与相应的结果:
A=imread('cameraman.tif');
tform=affine2d([1 0 0 ; 0.05 1 0 ; 0 0 1]);
J=imwarp(A, tform, 'OutputView',imref2d(size(A)));
subplot(1,3,1)
imshow(A),title('Original Image');
subplot(1,3,2)
imshow(J),title('Rotated Image');
zeropixels = J == 0;
J(zeropixels) = A(zeropixels);
subplot(1,3,3)
imshow(J),title('Correct Image');
你试过了什么? – FeedTheWeb
@lxer:我正在尝试[像这样](http://stackoverflow.com/questions/7742601/to-replace-black-portion-of-an-image-with-any-other-image-in-matlab ) – erbal