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

2 Ansichten (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
Rik
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?

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