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 Kommentare12 ältere Kommentare anzeigen12 ältere Kommentare ausblenden
Rik am 9 Mär. 2023
I cannot do that, because I don't know how to warp the image to remove the discontinuities that would result from removing those blobs.
You keep repeating code. I keep repeating you don't need code yet. First define what you want to do, then start implementing it. You have explained what you want to do.
You are making a start with your definition. You want to measure some sort of density (or packing ratio, etc), and you want to disregard the area with the black blobs when performing this calculation. Would that be a fair description?
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 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare 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

Mehr zu Region and Image Properties 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