Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
help needed in image segmentation.
조회 수: 1 (최근 30일)
이전 댓글 표시
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...............
댓글 수: 0
답변 (1개)
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
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!