How to find the internal and external radius of a ring using matlab image processing toolbox

13 views (last 30 days)
For example get this image

Accepted Answer

Akira Agata
Akira Agata on 13 Nov 2017
By measuring the 'equivalent diameter' for each region, you can obtain the inner and outer radius. Here is an example.
% Read your image and binarize it
I = imread('Oil_Seal_Top_370003A__34285.1413827494.1280.1280.jpg');
Igray = rgb2gray(I);
BW = imbinarize(Igray);
% Measure the outer radius
BWout = ~BW;
BWout = imfill(BWout,'holes');
statOuter = regionprops(BWout,{'EquivDiameter','Centroid'});
outerRadius = statOuter.EquivDiameter/2;
% Measure the inner radius
BWin = imclearborder(BW);
BWin = imopen(BWin, strel('disk',5)); % Remove noise
statInner = regionprops(BWin,{'EquivDiameter','Centroid'})
innerRadius = statInner.EquivDiameter/2;
% Show the result
figure
imshow(I)
hold on
viscircles(statOuter.Centroid, outerRadius,'Color','r')
viscircles(statInner.Centroid, innerRadius,'Color','r')
The result is:
>> innerRadius
innerRadius =
278.8980
>> outerRadius
outerRadius =
374.5866
  1 Comment
Rangika Mark
Rangika Mark on 13 Nov 2017
Thank you Mr.Akira Agata for mind me the solutions this is simple,early I used imfindcircle function in that I have to input the pixel value

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing Toolbox 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!