How to down scale image in keras for an image pyra

2019-08-23 11:58发布

问题:

I'd like to use an image pyramid for deep learning as in Deep Multi-scale for Deblurring. How can I down scale images on the fly when using keras?

回答1:

You could use an Average Pooling layer if the downscale rate is an integer.

o = AveragePooling2D(pooling_size=(2, 2))(i)

This will average a 2x2 window into a single pixel, which is a fairly accurate way of resizing an image by a factor of 2.



回答2:

You can find Gaussian pyramids using OpenCV. cv2.pyrUp() and cv2.pyrDown() functions can be used to upsample and downsample the image respectively. For more reference see: this link