1
votes

Suppose i have a 256*256 matrix(image pixel values).I want to create that Sliding window 1 to Sliding Window n by shifting exactly one row and one column. All the Sliding Window Matrix Should be in the size of 5*5.

I have tried with this following code. By this i am getting the submatrices but not by the shifting of exactly one row and one column.

I = imread('D:\Study Material\project\Finger Print Database\1_2.png');

J = imresize(I, [128 128]);

C=mat2tiles(J,[5,5]);
  • Suppose original matrix has 10 row and 10 column.
  • I'm getting the sub-matrices like (column1-column5 & row1-row5) then (column6-column10 & row6-row10).
  • But I need like this- (column1-column5 & row1-row5)then (column2-column6 & row1-row5)like this first column will be shifted to 10. After that row will be shifted to 10.
1
I think the example of what you need is incorrect. Your second window has grown to 5x6 instead of 5x5.beaker
That's my mistake.It should be (column2-column6 & row1-row5)Arijit Panigrahi

1 Answers

1
votes

You need im2col with the 'sliding' option, followed by reshape:

blockSize = [5 5];
C = reshape(im2col(J, blockSize, 'sliding'), blockSize(1), blockSize(2), []);