having difficulty in simple circle detection

3 ビュー (過去 30 日間)
Abhilash Uniyal
Abhilash Uniyal 2020 年 5 月 11 日
コメント済み: Abhilash Uniyal 2020 年 5 月 11 日
Hi,
I am having difficulty finding a circle.
I already tried 'imfindcirles' , with different sensitivity but failed.
please help in this. i want to find the radius and center point of the dark blue circel (image attached).
Thanks in advance.

採用された回答

Image Analyst
Image Analyst 2020 年 5 月 11 日
編集済み: Image Analyst 2020 年 5 月 11 日
Use the Color Thresholder app on the apps tab of the tool ribbon. I'd use hsv color space. Then adjust the thresholds and Export the code into a new function m-file.
rgbImage = imread('Captur11.jpg');
subplot(2, 1, 1);
imshow(rgbImage);
[BW,maskedRGBImage] = createMask(rgbImage);
% Fill holes
BW = imfill(BW, 'holes');
% Take largest blob.
BW = bwareafilt(BW, 1);
subplot(2, 1, 2);
imshow(BW)
function [BW,maskedRGBImage] = createMask(RGB)
%createMask Threshold RGB image using auto-generated code from colorThresholder app.
% [BW,MASKEDRGBIMAGE] = createMask(RGB) thresholds image RGB using
% auto-generated code from the colorThresholder app. The colorspace and
% range for each channel of the colorspace were set within the app. The
% segmentation mask is returned in BW, and a composite of the mask and
% original RGB images is returned in maskedRGBImage.
% Auto-generated by colorThresholder app on 11-May-2020
%------------------------------------------------------
% Convert RGB image to chosen color space
I = rgb2hsv(RGB);
% Define thresholds for channel 1 based on histogram settings
channel1Min = 0.584;
channel1Max = 0.619;
% Define thresholds for channel 2 based on histogram settings
channel2Min = 0.856;
channel2Max = 1.000;
% Define thresholds for channel 3 based on histogram settings
channel3Min = 0.000;
channel3Max = 1.000;
% Create mask based on chosen histogram thresholds
sliderBW = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ...
(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);
BW = sliderBW;
% Initialize output masked image based on input image.
maskedRGBImage = RGB;
% Set background pixels where BW is false to zero.
maskedRGBImage(repmat(~BW,[1 1 3])) = 0;
end
  3 件のコメント
Image Analyst
Image Analyst 2020 年 5 月 11 日
編集済み: Image Analyst 2020 年 5 月 11 日
Try this:
props = regionprops(BW, 'Centroid', 'EquivDiameter');
radius = props.EquivDiameter / 2;
xCenter = props.Centroid(1);
yCenter = props.Centroid(2);
[r, g, b] = imsplit(rgbImage);
meanR = mean(r(BW))
meanG = mean(g(BW))
meanB = mean(b(BW))
Abhilash Uniyal
Abhilash Uniyal 2020 年 5 月 11 日
Thank you, It worked :)

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by