Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python中的图像处理–;无需将整个图像加载到内存中_Python_Image Processing_Memory Management_Numpy_Scipy - Fatal编程技术网

Python中的图像处理–;无需将整个图像加载到内存中

Python中的图像处理–;无需将整个图像加载到内存中,python,image-processing,memory-management,numpy,scipy,Python,Image Processing,Memory Management,Numpy,Scipy,我正在寻找一个python库,它允许我从TIF图像中检索图像数据,而无需将整个图像加载到内存中 我曾尝试使用numpy.memmap,但在文件中查找图像数据时遇到困难。任何建议都会有帮助。谢谢 我有两个建议: 将图像数据分块读入Python: with open('path/to/image-data.tif', 'rb') as tif: while True: chunk = tif.read(4096) if not chunk:

我正在寻找一个python库,它允许我从TIF图像中检索图像数据,而无需将整个图像加载到内存中


我曾尝试使用
numpy.memmap
,但在文件中查找图像数据时遇到困难。任何建议都会有帮助。谢谢

我有两个建议:

  • 将图像数据分块读入Python:

    with open('path/to/image-data.tif', 'rb') as tif:
        while True:
            chunk = tif.read(4096)
            if not chunk:
                break
    
  • 考虑使用NumExpr进行处理:

  • 。。。在内部,NumExpr使用其自己的矢量化虚拟机,该虚拟机是围绕分块读取策略设计的,以便有效地操作内存中大小最佳的数据块。如果调整得当,它可以轻松击败幼稚的NumPy操作


    希望这有帮助,祝你好运

    图像有多大?试试
    pyvips
    ——它速度快,内存省。