HELP!! No matter how big I set the threshold THE OBJECTS I DON'T WANT ARE NOT HIGHLIGHTED!!!

1 Ansicht (letzte 30 Tage)
% Read image as RGB
I = imread('TEST.TIF'); %including the pull path is better
% Convert to binary
BW = imbinarize(rgb2gray(I));
% Get rid of white border
BWConv = bwconvhull(~BW);
BW = BW & BWConv;
% get region centers and major axis, and orientation
stats = regionprops('table',BW,'BoundingBox','MajorAxisLength','MinorAxisLength');
% Compute length/width ratio
stats.LenWdRatio = stats.MajorAxisLength ./ stats.MinorAxisLength;
% Set threshold and determine which objects
% are greater than the threshold.
thresh = 10000.0;
stats.isGreater = stats.LenWdRatio > thresh;
% Show bounding box for objects that met the threshold
figure()
h = imshow(BW);
axis on
hold on
% Plot red rectangles around accepted objects
arrayfun(@(i)rectangle('Position',stats.BoundingBox(i,:),'EdgeColor','r'), find(stats.isGreater));
% Plot yellow rectangles around rejected objects
arrayfun(@(i)rectangle('Position',stats.BoundingBox(i,:),'EdgeColor','y'), find(~stats.isGreater));
I dont want those big black circles in my image but I can't determine their threshold to highlight them. PLEASE HELP!! This is really doing me in a good one in a bad way, thanks!!
It should look like this (yellow is rejected) where I've circled some of the rejected objects:
  14 Kommentare

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 10 Mär. 2023
I believe you need to compute the Euclidean Distance Transform with bwdist and then threshold it. Then call bwareaopen to extract just the biggest regions. Try it.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by