why overwrite cell in loop matlab?

1 view (last 30 days)
jenifer Ask
jenifer Ask on 26 Dec 2019
Commented: jenifer Ask on 26 Dec 2019
Hi
I try to calculate the distance of some picture, But on this Code, just remain the matrix distance of final picture.
Of course I see By F10 each output of distance of the points x1{i},y1{i} of the picture
image 1 have 15 points
image 2 have 22 points
image 3 have 18 points,... and mage 6, have 47 points,
this picture, result showed run my code that remain the matrix distance of final image.
vecPoint{i}=[x1{i},y1{i}];
[m{i} n{i}] = size(vecPoint{i});
n{i} = m{i};
Dist{i} = zeros(m{i}, n{i});
for ii = 2 : m{i}
for jj = 2 : n{i}
%%%%%%%%%%%%%%% Here %%%%%%%%%%%%%%%%%%%%%%%%%
Dist{jj,ii} = sqrt((vecPoint{i}(ii, 1) - vecPoint{i}(jj, 1)) ^ 2 + ...
(vecPoint{i}(ii, 2) - vecPoint{i}(jj, 2)) ^ 2);
end
end
maaathw.PNG
  2 Comments
Image Analyst
Image Analyst on 26 Dec 2019
Well it's doing what you're telling it to do. But what I don't know, is what you want it to do. What value does the poorly-named "i" have? Is that the loop iterator over images from 1 to 6? So all of that code is actually part of the inside of a loop over i? Why are you not using pdist2()? Do you not have the stats toolbox?
jenifer Ask
jenifer Ask on 26 Dec 2019
'Why are you not using pdist2()? Do you not have the stats toolbox?'
I used But out put matrix have different calculate distance
for example, result for one image with D = pdist2(x1,y1,'euclidean'); (picture 2) . and mycode (picture 1)
mycode.jpg
pdist.jpg

Sign in to comment.

Answers (0)

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!