Returning specific regions of a labeled image

1 回表示 (過去 30 日間)
med-sweng
med-sweng 2013 年 12 月 19 日
回答済み: Image Analyst 2013 年 12 月 19 日
Say that I have a labeled image, where I have calculated the area of each region. How can I return specific regions? That is, say I want to return the regions that have >=297 and <676?
Thanks.

回答 (1 件)

Image Analyst
Image Analyst 2013 年 12 月 19 日
You can get all areas into an array
allAreas = [measurements.Area];
Now find out which blobs meet your criteria with thresholding and find(). Then extract those blobs with ismember(). Here is a snippet from my tutorial:
% Now I'll demonstrate how to select certain blobs based using the ismember function.
% Let's say that we wanted to find only those blobs
% with an intensity between 150 and 220 and an area less than 2000 pixels.
% This would give us the three brightest dimes (the smaller coin type).
allBlobIntensities = [blobMeasurements.MeanIntensity];
allBlobAreas = [blobMeasurements.Area];
% Get a list of the blobs that meet our criteria and we need to keep.
allowableIntensityIndexes = (allBlobIntensities > 150) & (allBlobIntensities < 220);
allowableAreaIndexes = allBlobAreas < 2000; % Take the small objects.
keeperIndexes = find(allowableIntensityIndexes & allowableAreaIndexes);
% Extract only those blobs that meet our criteria, and
% eliminate those blobs that don't meet our criteria.
% Note how we use ismember() to do this.
keeperBlobsImage = ismember(labeledImage, keeperIndexes);
% Re-label with only the keeper blobs kept.
labeledDimeImage = bwlabel(keeperBlobsImage, 8); % Label each blob so we can make measurements of it

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by