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

1 Ansicht (letzte 30 Tage)
Laura am 9 Mär. 2023
Kommentiert: Laura am 10 Mär. 2023
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 Kommentare13 ältere Kommentare anzeigen13 ältere Kommentare ausblenden
Chanille am 9 Mär. 2023
Exactly!!

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

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.
##### 1 KommentarKeine anzeigenKeine ausblenden
Laura am 10 Mär. 2023
@Image Analyst Holy guacomole!!! I think I got it!!!! Thank YOU!! @Image Analyst

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Texture Analysis in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by