Returning specific regions of a labeled image

2 vues (au cours des 30 derniers jours)
med-sweng
med-sweng le 19 Déc 2013
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.

Réponses (1)

Image Analyst
Image Analyst le 19 Déc 2013
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

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by