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

13 ビュー (過去 30 日間)
For example get this image

採用された回答

Akira Agata
Akira Agata 2017 年 11 月 13 日
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 件のコメント
Rangika Mark
Rangika Mark 2017 年 11 月 13 日
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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by