quality of the circles found - imfindcircles

2 views (last 30 days)
Hello,
I am unsing imfindcircles with a greyscale image. Some of the circles identified are good, and some are not so good.
I am now overlapping the circles identified onto the original image and inspect visually.
Does someone know if there is another way of quantifying the quality of the circles found?

Answers (3)

Image Analyst
Image Analyst on 20 Nov 2018
The third output of imfindcircles() gives you a metric.
Circle strengths is the relative strengths for the circle centers, returned as a vector. The value at metric(j) corresponds to the circle with radiusradii(j) centered at centers(j,:).

Marcel Verduyn
Marcel Verduyn on 21 Nov 2018
Thanks for this.
Yest, there is some difference in the relative strengths of the droplets identified in the image below. Still, when I continue the iteration which is now set till 60, I find many circles which should not have been identified.
My code is in development and suggestions are very welcome.
close all;
clear all;
clc;
%Input image
img = imread ('Capture.jpg');
%Show input image
figure, imshow(img);
img = rgb2gray(img);
figure, imshow(img);
[BW,maskedImage,metric] = segmentImage(img);
figure, imshow(maskedImage);
metric(1:10)
figure, histogram(metric)
stats = regionprops('table',BW, 'Centroid',...
'MajorAxisLength','MinorAxisLength');
centers = stats.Centroid;
diameters =mean([stats.MajorAxisLength stats.MinorAxisLength],2);
radii = diameters/2;
figure, imshow(img)
hold on
viscircles(centers,radii)
hold off
function [BW,maskedImage,metric] = segmentImage(X)
%segmentImage Segment image using auto-generated code from imageSegmenter App
% [BW,MASKEDIMAGE] = segmentImage(X) segments image X using auto-generated
% code from the imageSegmenter App. The final segmentation is returned in
% BW, and a masked image is returned in MASKEDIMAGE.
% Auto-generated by imageSegmenter app on 14-Nov-2018
%----------------------------------------------------
% Find circles
[centers,radii,metric] = imfindcircles(X,[63 88],'ObjectPolarity','dark','Sensitivity',1);
BW = false(size(X,1),size(X,2));
[Xgrid,Ygrid] = meshgrid(1:size(BW,2),1:size(BW,1));
for n = 1:60
BW = BW | (hypot(Xgrid-centers(n,1),Ygrid-centers(n,2)) <= radii(n));
end;
% Create masked image.
maskedImage = X;
maskedImage(~BW) = 0;
end
Capture.JPG

Marcel Verduyn
Marcel Verduyn on 21 Nov 2018
Is this method implemented in Matlab?
I'd first like to try to improve the script I am using now because imfindcircles finds 8 large circles, of which only 1 does not match. Only when I increase the number of iteration steps (higher than 60) more unmatching circles are found.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!