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

11 vues (au cours des 30 derniers jours)
For example get this image

Réponse acceptée

Akira Agata
Akira Agata le 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 commentaire
Rangika Mark
Rangika Mark le 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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by