user570593
user570593

Reputation: 3520

matlab fast sliding windows with predefined overlap (im2col 'sliding' matlab)

I need to get local pixel histograms from a size of 10x10 sliding windows from an image of size NxN (N>>10).

I am using the follwing code to obtain the sliding windows.

       B = im2col(inputImage, [10, 10],'sliding');

But according to this code I cannot determine the overlap between two local windows. How can I get local histograms from image with a sliding window of size mxm and half overlap between two sliding windows?

Upvotes: 2

Views: 3831

Answers (1)

Amro
Amro

Reputation: 124563

IM2COL function always generates sliding windows with [n-1,m-1] overlap (i.e 1 pixel shifting). Perhaps you can call IM2COL as is, and then discard columns you dont want. Remember that the sliding windows are generated by traversing the matrix in a column-order manner.


A quick search revealed a custom im2colstep function, implemented as a MEX-file. In your case, you would call it as:

cols = im2colstep(inputImage, [10 10], [5 5]);

The function is part of KSVD-Box package, "available for free for academic and personal use" according to the author.

Upvotes: 6

Related Questions