[Solved] How to apply sliding window for subtracting two different images in matlab? [closed]


The upper bounds of your for-loops are the cause for your troubles.
You specify:

imh=size(ab,2);
imw=size(ab,1);

However, your for-loops have these conditions:

j=1:imh+wh-1

and

i=1:imw+ww-1

So you move past both the ‘height’ and the ‘width’ dimension.
Try this instead:

for j=1:imh-wh
    for i=1:imw-ww
        w1=ab(j:j+wh,i:i+wh,:);
        w2=salt(j:j+wh,i:i+wh,:);
        w3=w1-w2;
    end
    k=k+1;
end

1

solved How to apply sliding window for subtracting two different images in matlab? [closed]