Delete part of an image
2 次查看(过去 30 天)
显示 更早的评论
Hi, explain below what I want to do to see if anyone would know how to fix it.
I start with an image like the following:
Now I make two circles, one with a smaller radius than the other, of which I know both its center and radius. They're not concentric but they never intersect
And finally what I want to achieve is that all the points that are outside the major circle as well as inside the minor circle become black
0 个评论
采纳的回答
Matt J
2020-1-16
编辑:Matt J
2020-1-16
[m,n]=size(oldImage);
x=(1:n);
y=(1:m).';
mask = (x-innerCenterX).^2+(y-innerCenterY).^2>=innerRadius^2 & ...
(x-outerCenterX).^2+(y-outerCenterY).^2<=outerRadius^2 ;
newImage=oldImage.*mask;
3 个评论
Matt J
2020-1-16
Appropriate type conversions will fix it,
newImage=uint16( double(oldImage).*mask );
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!