2017-05-28 41 views
0

我想用Matlab从所有四边(左,右,上,下)中找出下图中显示的嵌套圆之间的距离。我发现这个圈子使用imfindcircle使用Matlab进行嵌套圆测量

下面是图片:

OpticCupDisc Image

+0

如果你使用了'imfindcircle',那么你有圆心和半径。从那里它只是算术。如果您在编码解决方案时遇到问题,请发布代码以及您正在讨论的*距离(最小,最大,平均值,所有距离?)。 – beaker

+0

是的,我有两个值,但我不知道如何使用它。我需要从所有侧面(顶部,底部,左侧,右侧)的外侧圆的内侧圆的边缘之间找到距离 –

+0

您是否研究了距离度量[这里](https://www.mathworks.com/help/stats/pdist2.html)? – kedarps

回答

0

您可以遵循这样的事情。首先,从图像中删除白色背景。我在这里使用了输入,我假设你使用imfindcircle寻找圈子,所以你应该有中心在手。使用中心坐标,我会画出极端点,顶部,左侧,底部和右侧,然后计算这些点与中心之间的距离。

rgbImage = imread('JjkrL.jpg') ; 
%% Remove the white background 
grayImage = min(rgbImage, [], 3); 
binaryImage = grayImage < 200; 
binaryImage = bwareafilt(binaryImage, 1); 
[rows, columns] = find(binaryImage); 
row1 = min(rows); 
row2 = max(rows); 
col1 = min(columns); 
col2 = max(columns); 
% Crop 
croppedImage = rgbImage(row1:row2, col1:col2, :); 
[nx,ny,t] = size(croppedImage) ; 
imshow(croppedImage) ; 
%% 
% Centers of circles 
C1 = [84 142] ; 
C2 = [76 136] ; 

%% Get distances 
% circle 1/ Big circle 
% Edge points 
top = [C1(1) 1] ; 
bottom = [C1(1) nx] ; 
left = [1 C1(2)] ; 
right = [ny C1(2)] ; 
pts = [top ;left ;bottom ; right] ; 

hold on 
plot(C1(1),C1(2),'*r') 
plot(pts(:,1),pts(:,2),'*k') ; 
%% Get distances 
data = repmat(C1,[length(pts),1])-pts ; 
dist = sqrt(data(:,1).^2+data(:,2).^2);