How to detect the inner part of the core?
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Sulaymon Eshkabilov
on 13 Jan 2023
Have you seen the code proposed by Image Analyst: https://www.mathworks.com/matlabcentral/answers/245026-shape-detection-in-image
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!