How to detect the inner part of the core?

2 ビュー (過去 30 日間)
muhammad choudhry
muhammad choudhry 2023 年 1 月 13 日
コメント済み: muhammad choudhry 2023 年 1 月 13 日
Hi,
I am trying to figure out how to find out the size of the core in the image, inner part for example best fit circle btu I am struggling, please see the code below I tried, and the images core is the main imafe and circle not fit is what I have tried so far. even if I can get some sort of contour of the inner core and extract the points and put the best fit circle but so far like 5 - 6 hours and no success here. Help would be great.
% Read in image
img = imread('Export.6t9zq5l4.000022a.jpg');
%[J,rect] = imcrop(img);
img = imcrop(img, [1030.51000000000,650.510000000000,638.980000000000,599.980000000000]);
% Convert image to grayscale
gray_img = rgb2gray(img);
% Smooth image
gray_img = medfilt2(gray_img, [3 3]);
% Apply threshold to grayscale image
threshold = graythresh(gray_img);
gray_img = imbinarize(gray_img, threshold);
gray_img = bwareaopen(gray_img, 1000);
figure(1)
imshow(gray_img)
se = strel('disk', 10);
dilated_img = imdilate(gray_img, se);
figure(2)
imshow(dilated_img)
eroded_img = imerode(dilated_img, se);
figure(3)
imshow(eroded_img)
[centers, radii] = imfindcircles(eroded_img, [40 55], 'ObjectPolarity','bright', 'Sensitivity',0.1);
viscircles(centers, radii, 'Color', 'r', 'LineWidth', 2);
figure(4)
imshow(eroded_img);
hold on;
viscircles(centers, radii, 'Color', 'r', 'LineWidth', 2);
hold off;

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 1 月 13 日
  1 件のコメント
muhammad choudhry
muhammad choudhry 2023 年 1 月 13 日
Yea, the core is not basically well defined circle or ellipse hence what is in the link above not capturing accurately.

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

カテゴリ

Help Center および File ExchangeGet Started with Image Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by