error in calculating distance

I have a image and have divided it into blocks
C = mat2cell(I,[128 128],[128 128])
my output is
C =
[128x128 uint8] [128x128 uint8]
[128x128 uint8] [128x128 uint8]
i have taken first block
A1=I(1:128, 1:128);
i want to calculte distance of A1 with C1 ,i tried euclidean distance but i get error
Error in ==> EuD at 23
Distance= sqrt(d);

댓글 수: 9

Pat
Pat 2012년 1월 13일
pleas help to find the distance
Grzegorz Knor
Grzegorz Knor 2012년 1월 13일
How do you calculate d?
Image Analyst
Image Analyst 2012년 1월 13일
Is d the Pythagorean theorem between each pixel's intensity, like sqrt(A1 - C1)? Wouldn't that be zero? What is C1? Is that the first block? Well isn't that also A1? So the difference would be zero?
Pat
Pat 2012년 1월 13일
function Distance=EuD(A,B)
[row,col]=size(B);
% load histogram;
% A=A{1};
for i=1:row
for j=1:col
D(i,j)=(A(i,j)- B(i,j))^2;
end
end
% To find the sum of D
d=0;
for i=1:row
for j=1:col
d=(D(i,j)+d);
end
end
Distance= sqrt(d);
S the first ditsance is zero,but how to calculate tahe distance between others
Image Analyst
Image Analyst 2012년 1월 13일
Well why wouldn't your (inefficient, non-vectorized) function work for any A and B you pass in? Why not use RMS Error or PSNR instead?
Walter Roberson
Walter Roberson 2012년 1월 13일
You do not show us the error message, and you do not show us what C1 is.
Pat
Pat 2012년 1월 14일
Error in ==> EuD at 23
Distance= sqrt(d);
C1=[128x128 uint8]
Image Analyst
Image Analyst 2012년 1월 14일
That's not an official MATLAB error message - the text that shows up in red in the command window. We need the official error message. Please, please simply copy and paste your command window - DON'T paraphrase.
Walter Roberson
Walter Roberson 2012년 1월 14일
C1 might be that size and data type, but did define it as
C1 = C{1,1};
or as something else?

댓글을 달려면 로그인하십시오.

답변 (0개)

태그

질문:

Pat
2012년 1월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by