Cut an image based on pixel size
2 次查看(过去 30 天)
显示 更早的评论
Hi All,
Is there a way by which we can separate an image based on pixel size ? Please refer this picture. https://picasaweb.google.com/116243239493929305987/December142011#5685847768746798658
I would like to cut the image say " 200 black pixels boundary to boundary" and I would like to get an output like below.
Is this possible?? Thanks in advance.
0 个评论
采纳的回答
David Young
2011-12-14
You can cut the blob up using morphological operations, as shown below.
A point on terminology: all pixels are the same size (in a conventionally sampled image anyway). The blobs are to be separated based on the width of any "necks" that they have.
The width of the necks in the image as downloaded is much less than the 200 pixels you mention in your example, but maybe your images are actually much larger. To adjust my code, you would change the value of the variable cutsize.
% image downloaded and stored as imorig
imbin = imorig(:,:,1) > max(imorig(:))/2; % binarise
imclean = ~bwareaopen(imbin, 10); % remove dots just inside the edge, and invert
cutsize = 5; % half the thickness of the thickest neck to cut
ime = imerode(imclean, strel('disk',cutsize)); % cut necks
imthick = bwmorph(ime, 'thicken', cutsize); % grow blobs, but don't join up
imsplit = imbin | ~imthick; % split original image
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!