Why can't a circle be detected in such an obvious image?

2 ビュー (過去 30 日間)
cui,xingxing
cui,xingxing 2021 年 5 月 20 日
回答済み: Image Analyst 2021 年 5 月 21 日
Why can't a circle be detected in such an obvious image?
img = imread('circle.png');
[centers1,radii1] = imfindcircles(img,100,...
'Sensitivity',0.85,...
'ObjectPolarity','bright')
No matter how you adjust the value of 'sensitivity' or the radius or 'ObjectPolarity', the circle is not detected, why?
os: win10
matlab R2021a

採用された回答

Image Analyst
Image Analyst 2021 年 5 月 21 日
Try increasing the sensitivity to 0.95
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
%--------------------------------------------------------------------------------------------------------
% READ IN IMAGE
folder = pwd;
baseFileName = 'circle1.png';
grayImage = imread(baseFileName);
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage)
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
grayImage = min(grayImage, [], 3);
end
%--------------------------------------------------------------------------------------------------------
% Display the image.
imshow(grayImage, []);
axis('on', 'image');
title('Binary Image', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
hFig = gcf;
hFig.WindowState = 'maximized'; % May not work in earlier versions of MATLAB.
drawnow;
[centers1, radii1] = imfindcircles(grayImage,[75, 125],'Sensitivity',0.95,'ObjectPolarity','bright')
viscircles(centers1, radii1, 'LineWidth', 4);

その他の回答 (1 件)

Stephan
Stephan 2021 年 5 月 20 日
編集済み: Stephan 2021 年 5 月 20 日
Use a range for radius input argument such as:
[centers1,radii1] = imfindcircles(img,[50 200],'Sensitivity',0.85,'ObjectPolarity','bright')
  1 件のコメント
cui,xingxing
cui,xingxing 2021 年 5 月 21 日
編集済み: cui,xingxing 2021 年 5 月 21 日
Hi, your solution is not working and still not detecting any results!
you can try code

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品


リリース

R2021a

Translated by