2017-05-28 11 views
0

Matlabを使用して、4つの辺(左、右、上、下)から下の画像に示されたネストされた円の間の距離を求めます。私はimfindcircleを使ってこのサークルを見つけました。あなたはこのようなものに従うことができるMatlabを使用したネストされた円の測定

OpticCupDisc Image

+0

'imfindcircle'を使用した場合は、中心と円の半径があります。そこからは算術だけです。ソリューションのコーディングに問題がある場合は、あなたのコードと、あなたが話している距離(最小、最大、平均、すべての距離?)を投稿してください。 – beaker

+0

はい私は両方の値を持っていますが、私はそれをどのように使うことができるのか分かりません。私はすべての側(上、下、左、右)から円の外側から内側の円の端の間の距離を見つける必要があります –

+0

あなたは距離の尺度を調べましたか? [ここ](https://www.mathworks.com/help/stats/pdist2.html)? – kedarps

答えて

0

:ここ

はイメージです。まず、画像から白い背景を削除します。私は円の中心を ginputを使ってここに持ってきました。 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); 
関連する問題