H=eye(3); for i = (baseIndex+1):length 'transform the image' H=homos{i-1}*H; z_ = H(3,1) * u + H(3,2) * v + H(3,3) ; u_ = (H(1,1) * u + H(1,2) * v + H(1,3)) ./ z_ ; v_ = (H(2,1) * u + H(2,2) * v + H(2,3)) ./ z_ ; transformedImgs{i} = vl_imwbackward(im2double(images{i}),u_,v_) ; transformedWeights{i} = vl_imwbackward(im2double(weights{i}),u_,v_) ; transformedImgs{i}(isnan(transformedImgs{i})) = 0 ; transformedWeights{i}(isnan(transformedWeights{i})) = 0 ; end H=eye(3); for i = (baseIndex-1):-1:1 H=inv(homos{i})*H; z_ = H(3,1) * u + H(3,2) * v + H(3,3) ; u_ = (H(1,1) * u + H(1,2) * v + H(1,3)) ./ z_ ; v_ = (H(2,1) * u + H(2,2) * v + H(2,3)) ./ z_ ; transformedImgs{i} = vl_imwbackward(im2double(images{i}),u_,v_) ; transformedWeights{i} = vl_imwbackward(im2double(weights{i}),u_,v_) ; transformedImgs{i}(isnan(transformedImgs{i})) = 0 ; transformedWeights{i}(isnan(transformedWeights{i})) = 0 ; end
时间: 2023-03-30 15:01:45 浏览: 102
基本的图像变换
这是一段 MATLAB 代码,用于图像变换。其中使用了单应性矩阵 H,通过对多个单应性矩阵的叠加或逆叠加,实现对图像的变换。具体实现过程中,对每个图像像素的坐标进行变换,得到变换后的像素坐标,再通过反向映射得到变换后的图像。同时,对于变换后的像素坐标超出图像范围的情况,进行了处理,将其赋值为 。
阅读全文