Remove regions outside a range and find their centroids

조회 수: 2 (최근 30일)
Harry
Harry 2023년 7월 5일
댓글: Image Analyst 2023년 7월 7일
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.

답변 (1개)

Image Analyst
Image Analyst 2023년 7월 5일
편집: Image Analyst 2023년 7월 5일
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
Harry
Harry 2023년 7월 7일
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 2023년 7월 7일
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);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by