comarison of N images

1 次查看(过去 30 天)
praveen rai
praveen rai 2018-5-8
编辑: Stephen23 2018-5-8
suppose I have N images in my single folder let say n1,n2,n3,n4,n5,n6....(images no) i want to compare d images like this n1 and n2-o/p1 n2 and n3-o/p2 n3 and n4-o/p3 n4and n5 - o/p4 so on... al the output store in one location my for loop is not working plzz help me out thnx
  6 个评论
praveen rai
praveen rai 2018-5-8
编辑:Image Analyst 2018-5-8
data=[2 3 4 5 6 7];
%num=data;
size_data=size(data);
i=1;
temp=0;
for i=1:size_data
if (data(i) < data(i+1:end))
temp=data(i+1);
else
i=i+1;
end
end
My code in this is comparing 1st and 2nd elements.
Stephen23
Stephen23 2018-5-8
编辑:Stephen23 2018-5-8
@praveen rai: your code seems to have several bugs. For example size(data) returns a 1x2 vector [1,6], which you then use with colon operator as an input to for:
1:size_data
According to the colon help only the first element of non-scalar inputs is used, so your code is equivalent to
1:size_data(1)
which is equivalent to
1:1
which is equivalent to
1
So your loop iterates just once. Also your define a variable i before the loop: this will get ignored because you redefine i to be the loop iterator. Then inside the loop you increment i, but this will be discarded by the for on the next loop iteration.
The if input condition data(i) < data(i+1:end)) will always be true for the sample data. For values not in sequence this might not be true. In any case, regardless of how many times it might be true your code discards all temp allocations except for the very last one, because you did not use any operation to add/store all of the temp values into one value/array.
It is not clear what you are actually trying to do, so I cannot suggest any changes to your code.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by