2013-03-21 233 views
0

是否可以沿特定曲线裁剪图像。为前。我想从这幅图像中剪出手指图像,但我不想沿矩形裁剪它。 enter image description here在matlab中裁剪图像

+0

你有曲线的坐标你想裁剪?如果是这样,在哪种格式? – 2013-03-21 06:51:14

+1

您需要找到一个感兴趣的对象,制作它的二进制掩码并将图像放在掩码上。阅读有关边界查找和填充。 – 2013-03-21 06:59:18

+3

您知道它会以矩形形式出现,因为Matlab需要表示某种二维数组中的相关点... – bla 2013-03-21 07:03:25

回答

0

你需要一个二进制面膜,然后敷面膜是作为阿尔法地图 这里是它是如何完成通常

s = 100; 
h = imagesc(rand(s));%show some garbage 

%prepare a circular mask 
dummy = meshgrid(-s/2:s/2-1).^2;%squared distances from the center 
mask = sqrt(dummy+dummy') < 20;%20 is the radius of your mask 

%here you go, mask the image in a curved manner 
set(h,'alphaData',mask); 

导出为一个PNG会做这项工作。你需要制作自己的面具,这意味着要么你的位图图像的阈值或参数化空间(正如我用上面的圆圈做的那样)。