Constructing high resolution images in Python

◇◆丶佛笑我妖孽 提交于 2019-12-06 16:04:58

You say it "obviously can't be stored in memory", but the following calculations say otherwise.

20,000 * 20,000 pixels * 4 channels = 1.6GB

Most reasonably modern computers have 8GB to 16GB of memory so handling 1.6GB shouldn't be a problem.

However, in order to handle the patchworking you need to do, you could stream each pixel from one file into the other. This assumes the format is a lossless bitmap using a linear encoding format like BMP or TIFF. Simply read each file and append to your result file.

You may need to get a bit clever if the files are different sizes or patched together in some type of grid. In that case, you'd need to calculate the total dimensions of the resulting image and offset the file writing pointer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!