How can I efficiently process a numpy array in blocks similar to Matlab's blkproc (blockproc) function

后端 未结 6 1303
我在风中等你
我在风中等你 2020-11-27 02:55

I\'m looking for a good approach for efficiently dividing an image into small regions, processing each region separately, and then re-assembling the results from each proces

6条回答
  •  一向
    一向 (楼主)
    2020-11-27 03:31

    Process by slices/views. Concatenation is very expensive.

    for x in xrange(0, 160, 16):
        for y in xrange(0, 160, 16):
            view = A[x:x+16, y:y+16]
            view[:,:] = fun(view)
    

提交回复
热议问题