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에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by