2

我正在使用 SURF 在 Matlab 中实现图像马赛克。问题是

outputView = imref2d(size(img1)*2);
Ir = imwarp(img2,tform,'OutputView',outputView); 

它产生

在此处输入图像描述

我想要这样的东西

在此处输入图像描述

如果我改变

outputView = imref2d(size(img1)*2);

outputView = imref2d(size(img1));

matlab 裁剪第二个图像,使其在转换后适合第一个图像大小。

4

1 回答 1

2

请注意,当您相对于目标平面扭曲图像时,这个新平面中的许多像素都等于 0。一个非常基本的算法是简单地对图像进行阈值处理,以便找到大于 0 的值,然后找到最大的边界框包含非零像素...然后裁剪:

[rows,cols] = find(Ir(:,:,1) > 0);
topLeftRow = min(rows);
topLeftCol = min(cols);
bottomRightRow = max(rows);
bottomRightCol = max(cols);

Ir_crop = Ir(topLeftRow:bottomRightRow, topLeftCol:bottomRightCol, :);
于 2016-10-07T13:24:14.287 回答