Numpy Resize/Rescale Image

后端 未结 7 2092
轻奢々
轻奢々 2020-12-02 06:38

I would like to take an image and change the scale of the image, while it is a numpy array.

For example I have this image of a coca-cola bottle: bottle-1

Whi

7条回答
  •  旧时难觅i
    2020-12-02 07:00

    While it might be possible to use numpy alone to do this, the operation is not built-in. That said, you can use scikit-image (which is built on numpy) to do this kind of image manipulation.

    Scikit-Image rescaling documentation is here.

    For example, you could do the following with your image:

    from skimage.transform import resize
    bottle_resized = resize(bottle, (140, 54))
    

    This will take care of things like interpolation, anti-aliasing, etc. for you.

提交回复
热议问题