Remove regions outside a range and find their centroids

2 Ansichten (letzte 30 Tage)
Harry
Harry am 5 Jul. 2023
Kommentiert: Image Analyst am 7 Jul. 2023
I'm analysing images of giant clam shells with the hope of automating the process of counting and measuring their daily growth lines. I've been trying to find the centroids of the regions but as the images are not consistent I'm not sure this will be generealisable. I am only interested in the white regions with width around 30-200 pixels. How can I remove the other regions and find the centres of these lines? If this seems like the incorrect approach I would welcome any suggestions. I've attached the original and binarised images below.

Antworten (1)

Image Analyst
Image Analyst am 5 Jul. 2023
Bearbeitet: Image Analyst am 5 Jul. 2023
If you want the bounding box width to be between 30 and 200, do this
labeledImage = bwlabel(mask);
% Measure bounding boxes.
props = regionprops(labeledImage, 'BoundingBox')
allBB = vertcat(props.BoundingBox);
% Widths are column 3
widths = allBB(:, 3);
% Find out which widths are in the range we want.
keeperIndexes = find((widths >= 30) & (widths <= 200));
% Get a new binary image with only those blobs meeting the criteria.
mask = ismember(mask, keeperIndexes);
% Now get centroids and bounding boxes of what's left.
props = regionprops(labeledImage, 'BoundingBox', 'Centroid')
allBB = vertcat(props.BoundingBox);
% Get centroids as a matrix of (x,y) coordinates.
xyCentroids = vertcat(props.Centroid)
It's a generic, general purpose demo of how to threshold an image to find blobs, and then measure things about the blobs, and extract certain blobs based on their areas or diameters.
These look like tree rings. There is a center at the University of Arizona that is a world leader in Dendrochronology (study of tree rings). See if they can help you in your research.
You can also check the File Exchange for submissions on Vessel or Ridge finding filters, like Frangi, Hessian, B-COSFIRE
  2 Kommentare
Harry
Harry am 7 Jul. 2023
Thanks for your reply. I have done as you suggested and used
'keeperIndexes = find((widths >= 30) & (widths <= 200));'
to separate the regions. However when setting the first paramater to anything over 10 the whole image turns black even though there exist many regions with over 10 pixel width. These do look a lot like tree rings and function somewhat similarly. I'm hoping to be able to get the machine to identify and count a reasonable proportion of the lines. Do you think this approach is suitable?
Image Analyst
Image Analyst am 7 Jul. 2023
Yes it's possible to some degree, though not by using simple things like imbinarize(). And it won't be some short 200 line long program. To be robust the program will be much longer than that.
If there are indeed widths in the range 30-200, then the output mask from ismember should have them. I made a mistake though. The line of code should use the labeled image, not the mask.
mask = ismember(labeledImage, keeperIndexes);

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by