필터 지우기
필터 지우기

Geometric diagonal of a non-squared matrix

조회 수: 1 (최근 30일)
Ersilia Leonardis
Ersilia Leonardis 2012년 2월 7일
Hi everyone! I'm a learning matlab user and I've got a problem to solve: I need to extract a line segment from an image but it doesn't lie on the elements of the corresponding matrix. In other works, it would be like taking the main geometric diagonal of a rectangular matrix. How can I do that? Also, I wouldn't make any interpolation but just taking the closest elements to the line. Hope you can help me. Thanks!

답변 (1개)

Jonathan Sullivan
Jonathan Sullivan 2012년 2월 7일
Ersilia,
Assuming your image is a 2D matrix, you could take "the rectangular main diagonal" from it by using the following code.
% M is your image % v is the "rectangular main diagonal"
[a b] = size(M);
nPix = max(a,b);
xi = linspace(1,b,nPix);
yi = linspace(1,a,nPix);
v = interp2(M,xi,yi);
Hope this helps!

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by