Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting patches of a certain size from the image in python efficiently

I have an image and I want to extract square patches of different sizes from it.

I need dense patches, that is, I need a patch at every pixel in the image.

For example if the image is 100x100 and the patch size is 64.

The result will be 10000 patches of size 64x64

These are the same patches which we use for filtering operations for example.

In case there is a boundary I would like to mirror the image.

What is the most efficient way of extracting patches using python?

Thanks

like image 517
Shan Avatar asked Nov 28 '22 01:11

Shan


1 Answers

I think you are looking for something like this:

http://scikit-image.org/docs/0.9.x/api/skimage.util.html#view-as-windows

like image 60
Stefan van der Walt Avatar answered Dec 04 '22 08:12

Stefan van der Walt