Most efficient way to calculate radial profile

后端 未结 4 1420
误落风尘
误落风尘 2020-12-02 12:32

I need to optimize this part of an image processing application.
It is basically the sum of the pixels binned by their distance from the central spot.

d         


        
4条回答
  •  独厮守ぢ
    2020-12-02 13:06

    There is a function in PyDIP that does just this: dip.RadialMean. You can use it in a similar way to OP's radial_profile function:

    import PyDIP as dip
    
    img = dip.ImageReadTIFF('crop.tif')
    # center, radi = find_centroid(img)
    center, radi = (509, 546), 55
    rad = dip.RadialMean(img, binSize=1, center=center)
    
    rad[radi:].Show()
    

    Disclaimer: I'm an author of PyDIP and the DIPlib library.

提交回复
热议问题