Cut an image based on pixel size

1 回表示 (過去 30 日間)
Shan  Kapoor
Shan Kapoor 2011 年 12 月 14 日
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.

採用された回答

David Young
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
  1 件のコメント
Shan  Kapoor
Shan Kapoor 2011 年 12 月 14 日
Shan Kapoor less than a minute ago Delete
Hi David,
This code solves my problem to an extend. I was trying an ImageJ plugin http://www.gcsca.net/IJ/Shapes.html combined with watershed segmentation ( watershed and remove clusters of pixels less than a certain range). this code works as a replacement to that. thank you for sharing.
Regards,
Shanoob

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Filtering and Enhancement についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by