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]);
You need im2col
with the 'sliding'
option, followed by reshape
:
blockSize = [5 5];
C = reshape(im2col(J, blockSize, 'sliding'), blockSize(1), blockSize(2), []);