How to manage large images in Python using OpenCV?

I am trying to figure out a massive numpy array, after which I end up recording a JPEG image with cv2.imwrite(numpy.array). Unfortunately, what I'm working with does not fit into my RAM, although the final image in JPG format should be up to 200 MB.

How can I manage such loads without overloading my RAM?

Are there other ways to record an image without saving the entire array in my RAM right away? This allows me to load small bits of an array at a time, but I don’t know which module / function to use to write to the image without immediately saving all the contents of my RAM.

As of now, I saved the entire image in 4 small images (quarters), because this is the best I could do with my limited RAM. But I still want them to be able to sew them together into one complete image. The target image is a three-channel image of 26112 x 20480.

+4
source share
2 answers

If the image is 26112 x 20480 with three channels, one byte per channel, uncompressed data takes up 3 x 26112 x 20480 bytes, which is about 1.5 gigabytes. A JPEG file can be much smaller because it uses lossy compression, but it does not have an OpenCV representation.

(, ) , Jpegtran, , d OpenCV . , DCT- 8x8, , OpenCV .

, OpenCV, numpy - . , , , , , . , . mmap , , OpenCV, .

+2

. , , - Eigen. .

OpenCV .

+1

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


All Articles