help with "imfindcircles"

조회 수: 5 (최근 30일)
calistaird
calistaird 2020년 12월 5일
댓글: Image Analyst 2020년 12월 22일
Hello! i am having trouble finding the centroid of this petri dish.
when i run my code, matlab finds 12 centroids and when i use 'viscircles' its showing me 12 rings on top of each other. could this be a sensitivity issue? are there other ways i can eliminate the other circles and only detect the boundary of the petri dish?
here is my code and i have also attached the image im analyzing and the resultant image after running the code
for i = 1:numI
file = images(i).name;
img = imread(file);
imshow(file)
% d = drawline;
% pos = d.Position;
% diffPos = diff(pos);
% diameter = hypot(diffPos(1),diffPos(2));
[C,R] = imfindcircles(img,200,'ObjectPolarity','dark','Sensitivity',1);
end
v = viscircles(C,R);

채택된 답변

Image Analyst
Image Analyst 2020년 12월 5일
Post your original image, rather than a screenshot.
For one thing, your image capture conditions are horrible. You need to have lights on both sides to get rid of that bad shadow that is essentially the same darkness as your petri dish. If you had that, you could simply threshold and call regionprops:
mask = grayImage < someThresholdValue;
% Take largest blob.
mask = bwareafilt(mask, 1);
% Fill holes
mask = imfill(mask, 'holes');
% Find centroid
props = regionprops(mask, 'Centroid', 'EquivDiameter')
xCenter = props.Centroid(1)
yCenter = props.Centroid(2)
diameter = props.EquivDiameter
  댓글 수: 2
Chaman Srivastava
Chaman Srivastava 2020년 12월 21일
Hey! Image Analyst.
Really appreciate your answers!
I have a question regarding imfindcircles command in Matlab. Why is that it always return interger values if i specify a range in the command. Any insights on this? Is there any method to extract much accurate values?
Image Analyst
Image Analyst 2020년 12월 22일
Not sure. I don't really use it that much. Maybe it always wants to put the center on a definite row and column. You can call them and ask them or edit imfindcircles.m to see the source code.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by