How to detect the inner part of the core?
2 次查看(过去 30 天)
显示 更早的评论
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;
0 个评论
回答(1 个)
Sulaymon Eshkabilov
2023-1-13
Have you seen the code proposed by Image Analyst: https://www.mathworks.com/matlabcentral/answers/245026-shape-detection-in-image
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!