edit-error in calculating dsit

조회 수: 1 (최근 30일)
kash
kash 2012년 2월 5일
I have the matrices as below
A1=Ds(121:140, 121:140, 1:7)
A2=Ds(121:140, 121:140,7)
plz tell how to find the euclidean distance ,like in my previous post

채택된 답변

Junaid
Junaid 2012년 2월 5일
Well I guess you want to get single scalar value as distance of A2 for each Chanel in A1. If so then I try to do in steps. There are multiple ways but I would do like this.
First i will make A2 as single column vector
n_A2 = A2(:);
then I will make one matrix by A1, where each column is one image.
n_A1 = zeros(length(n_A2), size(A1,3)); % this creates matrix of rows as length of and columns are equal to number of images in A1
for i=1:size(A1,3)
t= A1(:,:,i);
n_A1(:,i) = t(:);
end
and Finally now compute the Euclidean distance n_A2 with all images in n_A1
A= repmat(n_A2,1,size(n_A1,2));
E_distance = sqrt(sum((A-n_A1).^2));
Now E_distance contains the output distance. There must be one value 0 as you are taking query image from the same pool of images.
I wish it works for you. I executed this on small example. Once you get A1 and A2 from Ds. then copy paste the following code below. It is the same code written above.
n_A2 = A2(:);
n_A1 = zeros(length(n_A2), size(A1,3));
for i=1:size(A1,3)
t= A1(:,:,i);
n_A1(:,i) = t(:);
end
A= repmat(n_A2,1,size(n_A1,2));
E_distance = sqrt(sum((A-n_A1).^2));

추가 답변 (1개)

Junaid
Junaid 2012년 2월 5일
Could you please tell what is Ds ? for simplicity make Ds random matrix and then simplify your questions.
  댓글 수: 1
kash
kash 2012년 2월 5일
DS is an 3d image like cube ,formed from 2d slice

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

카테고리

Help CenterFile Exchange에서 Feature Detection and Extraction에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by