2014-02-28 34 views
1

我想从Matlab中使用图像切出圆形。 (1)和c(2)是到圆心的x,y坐标,r是半径。在Matlab中使用bsxfun创建一个圆形蒙板

mask = bsxfun(@plus, (1:256) - c(1)^2, (transpose(1:256) - c(2)^2)) < r^2; 

figure 
imshow(im(mask)); 

一切似乎工作,而不是面具我得到一个向量。

回答

1

这是((1:256) - c(1))^2而不是(1:256) - c(1)^2

mask = bsxfun(@plus, ((1:256) - c(1)).^2, (transpose(1:256) - c(2)).^2) < r^2; 

figure 
imshow((mask)); 
+0

非常感谢你! – jasheq

+0

非常欢迎您! – lennon310