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

조회 수: 2 (최근 30일)
% 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
Rik
Rik 2023년 3월 9일
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?

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

채택된 답변

Image Analyst
Image Analyst 2023년 3월 10일
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.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by