How to read large images as numpy.memmap objects

How can I read large images as objects so that I can control their pixels and save them back? Thanks in advance. numpy.memmap

+4
source share
1 answer

Without knowing further deatils, I would use scipy.misc.imread . Scipy uses Pillow , which in turn uses mmap :

>>> from scipy import misc
>>> pix_array = misc.imread('image_fname') # read only
>>> type(pix_array)
<type 'numpy.ndarray'>
>>> # manipulate pix_array to get `altered_pix_array`
>>> misc.imsave('altered_image_fname', altered_pix_array)

If it scipy.misc.imreaddoes not work right from the window, try pip install pillowinstalling / reinstalling Pillow correctly . GL + HF

+1
source

Source: https://habr.com/ru/post/1527620/


All Articles