rohan - when you step through the attached code, does the following line get called 18 times (I'm guessing this is how many images you are reading in based on the first for loop):
str = ['C:\Users\Public\Videos\Sample Videos\pro\Ne\im' num2str(m) '.jpg'] ;
If this line is invoked for every iteration of k, is it distinct on each iteration? I'm guessing it isn't, and here is why. Your first for loop iterates as:
However, there are several instances in the code where you re-use k for other purposes, and set it to 1 and then iterate again:
k=1;
for i=1:1:n
for j=1:2:n
if (j<=n-1)
s(i,k)=(b(i,j)+b(i,j+1))/2;
d(i,k)=b(i,j)-b(i,j+1);
end
k=k+1;
end
k=1;
end
This happens a handful of times including near the end:
for j=1:1:n/8
for i=1:2:n/4
if i<=n/4-1
s(k,j)=(b(i,j)+b(i+1,j)/2);
d(k,j)=b(i,j)-b(i+1,j);
end
k=k+1;
end
k=1;
end
b=imcrop(b,[0 0 64 64]);
m=k;
Note how k is reset to one after every completion of the inner for loop (on i). And then m is initialized to k…which means that m is always one and so probably im1.jpg is the only image ever being saved. (Is that correct?)
To correct this, k should never be modified by any inner loop within the code, just choose some other name for this alternate looping/indexing variable.
Best Answer