画像からの座標の読み取り

40 ビュー (過去 30 日間)
Chikako Kuriyama
Chikako Kuriyama 2017 年 7 月 26 日
コメント済み: Chikako Kuriyama 2017 年 7 月 28 日
読み込んだ画像かからエッジを摘出し、その角の座標を取得したいのですが、エッジを摘出したあとにどうすれば良いのかわかりません。
  6 件のコメント
Chikako Kuriyama
Chikako Kuriyama 2017 年 7 月 27 日
返信ありがとうございます。michioさんが添付していただいた図を最終的に得たいと考えています。
michio
michio 2017 年 7 月 28 日
Image Analyst san, thanks for your offer :) If we see some hard-core image processing issues next time, I'll reach out to you!

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

採用された回答

Tohru Kikawada
Tohru Kikawada 2017 年 7 月 27 日
画像処理でやりたいことがある場合には Image Processing Toolbox の例 をまずは探されることをおすすめします。
たとえば、 こちら のサンプルを活用することでやりたいことが実現できるかと思います。
ご参考まで。
%%Detect Lines in Images Using Hough
% This example shows how to detect lines in an image using the |hough| function.
%%Read an image into the workspace and binarize it
I = imread('https://jp.mathworks.com/matlabcentral/answers/uploaded_files/83898/%3F.png');
BW = imbinarize(rgb2gray(I));
BW = imclearborder(BW);
%%Compute the Hough transform of the binary image returned by |edge|.
[H,theta,rho] = hough(BW);
%%Display the transform, |H|, returned by the |hough| function.
figure
imshow(imadjust(mat2gray(H)),[],...
'XData',theta,...
'YData',rho,...
'InitialMagnification','fit');
xlabel('\theta (degrees)')
ylabel('\rho')
axis on
axis normal
hold on
colormap(gca,hot)
%%Find the peaks in the Hough transform matrix, |H|, using the |houghpeaks|
% function.
P = houghpeaks(H,5,'threshold',ceil(0.3*max(H(:))));
%%Superimpose a plot on the image of the transform that identifies the peaks.
x = theta(P(:,2));
y = rho(P(:,1));
plot(x,y,'s','color','black');
%%Find lines in the image using the |houghlines| function.
lines = houghlines(BW,theta,rho,P,'FillGap',30,'MinLength',50);
%%Create a plot that displays the original image with the lines superimposed
figure, imshow(I), hold on
max_len = 0;
len = zeros(length(lines),1);
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',1,'Color','green');
% Presave line length
len(k) = norm(lines(k).point1 - lines(k).point2);
end
%%Connect lines
theta = [lines.theta];
theta(theta>0) = -Inf;
[~,min_angle] = max(theta);
theta = [lines.theta];
theta(theta<0) = Inf;
[~,max_angle] = min(theta);
pts = [lines(min_angle).point1; lines(min_angle).point2; lines(max_angle).point2;...
lines(max_angle).point1; lines(min_angle).point1];
plot(pts(:,1),pts(:,2),'LineWidth',2,'Color','red');
  1 件のコメント
Chikako Kuriyama
Chikako Kuriyama 2017 年 7 月 28 日
本当にありがとうございます。参考にさせていただきます。何度もありがとうございました。

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

その他の回答 (2 件)

Takuji Fukumoto
Takuji Fukumoto 2017 年 7 月 26 日
エッジ検出が終わっているということで、2値化された画像をお持ちの状態かと思います。 regionprops関数を利用するとその画像のパラメータを取得することができます。
取得するパラメータは指定したプロパティで決定でき、 どのような画像かによりますが、'BoundingBox'や'Extrema'などが使えるかもしれません。

Chikako Kuriyama
Chikako Kuriyama 2017 年 7 月 27 日
ありがとうございます!早速試してみます。

Community Treasure Hunt

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

Start Hunting!