フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

help needed in image segmentation.

1 回表示 (過去 30 日間)
mohammed
mohammed 2013 年 11 月 4 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hallo
After segmentation with 5 cluster i got this image. but it giving me more then 5 region . i want to keep the 5 largest region of each color and if there any smallest region it would take the color of that region.
please help me...............

回答 (1 件)

Image Analyst
Image Analyst 2013 年 11 月 4 日
See my demo, attached below. The code will let you extract the N largest or smallest blobs. However deciding which label to assign to the small blobs that get merged is not so straightforward, particularly when they may have 2 or more neighbors with different labels. For example, that olive green blob in the upper middle borders orange, brown, magenta, and green blobs. So which color should it take on?
  8 件のコメント
mohammed
mohammed 2013 年 11 月 14 日
still not able to solve the way u show me . plz help me..
Image Analyst
Image Analyst 2013 年 11 月 14 日
Here's the code simplified to pull out exactly the 5 largest blobs:
% Get all the blob properties.
[labeledImage, numberOfBlobs] = bwlabel(binaryImage);
blobMeasurements = regionprops(labeledImage, 'area');
% Get all the areas
allAreas = [blobMeasurements.Area];
numberToExtract = 5;
% Sort in order of largest to smallest.
[sortedAreas, sortIndexes] = sort(allAreas, 'descend');
% Extract the "numberToExtract" largest blobs using ismember().
biggestBlob = ismember(labeledImage, sortIndexes(1:numberToExtract));
% Convert from integer labeled image into binary (logical) image.
binaryImage = biggestBlob > 0;

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by