No products are associated with this question.
I'm not sure I understand why you can't just have two for loops where you move the window along:
for row = 1 : windowSize : rows-windowSize for col = 1 : windowSize : columns-windowSize % Get rectangular block. thisBlock = yourImage(row:row+windowSize-1, column:column+windowSize-1); % Now process this block somehow... end end
It's the brute force, intuitive, totally obvious approach that I'm sure you've considered already, but what's wrong with it?
I only vaguely understand what you're doing, but nowhere in your code do you show where "block" originally comes from or how you update it. Maybe the problem is that you are not updating it.
Below might be something like what you're looking for for the 'embed' part. The 'extract' would probably be very similar. I'm using MAT2TILES which is available here
n=1; for r=1:2 for c=1:2 block(r,c)=bitset(block(r,c),1,embed(n)); n=n+1; block(r,c)=bitset(block(r,c),2,embed(n)); n=n+1; end end