how to find euclidean distance
이전 댓글 표시
I want to find the relative Euclidean distance of a pixel to its 8 neighbours. Kindly help me with the function or relative formula.
a=imread('duck.png');
max=std2(a);
b=rgb2ycbcr(a);
sdy=std2(b);
N=sdy/max;
H=1-N;
di=dist(b);
The error message is:
??? Error using ==> ctranspose
Transpose on ND array is not defined.
Error in ==> boiler_weight at 36
if nargin < 2,b=a; a=a'; end
Error in ==> dist at 90
boiler_weight
Error in ==> roughuse at 7
di=dist(b);
Kindly help me to solve this.
답변 (2개)
cr
2013년 2월 7일
0 개 추천
your matrix b is 3-D. try using dist function on 2D slices of matrix b.
Image Analyst
2013년 2월 7일
0 개 추천
Your question is not clear. The Euclidean distance of a pixel to it's neighbors in x-y space is either 1 or sqrt(2). But it looks like maybe you wanted the distance in Y-Cb-Cr color space, which is quite different. For that you'd need to extract the Y, Cb, and Cr component of each pixel and use the formula sqrt((y2-y1)^2 + (Cb2-Cb1)^2 + (Cr2-Cr1)^2).
By the way, don't use "max" as a variable name because you'll destroy the built in max() function!!!!!!!!!!!!!!!!
댓글 수: 3
Mohammed Qusay
2017년 3월 2일
hi im trying to detect the hands from face skin color managed to detect the face and found the median of its colors in the Ycbcr space but i dont kow how to find the Euclidean distance so i can detect the hand .. any help ?
Walter Roberson
2017년 3월 2일
pdist() to find Euclidean distance.
Image Analyst
2017년 3월 2일
That distance, the distance between two points in a colorimetric space, is called "Delta E". I have a tutorial for it in my File Exchange http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!