Does imresize in PIL / scipy.misc only work for uint8 images? any alternatives?

It seems that imresizeimplemented in PIL/ scipy.misconly works for uint8 images

>>> import scipy.misc
>>> im = np.random.rand(100,200)
>>> print im.dtype
float64

>>> im2 = scipy.misc.imresize(im, 0.5)
>>> print im2.dtype
uint8

Is there any way around this? I would like to process HDR images and therefore have to deal with float64or images float32. Thank.

+4
source share
2 answers

Thanks to the comments of cgohlke. Below are two alternatives I found that work for floating-point images.

For single-channel images: im2 = scipy.ndimage.interpolation.zoom(im, 0.5)

: im2 = scipy.ndimage.interpolation.zoom(im, (0.5, 0.5, 1.0))

  1. OpenCV.

im2 = cv2.resize(im, (im.shape[1]/2, im.shape[0]/2))

, . , .

+10

mode = 'F' imresize

imresize(image, factor, mode='F')
+1

All Articles