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 CenterFile Exchange에서 Get 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