TIGRE icon indicating copy to clipboard operation
TIGRE copied to clipboard

Add projection binning utility

Open AnderBiguri opened this issue 2 years ago • 0 comments

a python code would be e.g.:

def BinProjection(array, factor, average=True):
    if average:
        if array.shape[0] % factor or array.shape[1] % factor:
            array = array[
                : (array.shape[0] // factor) * factor, : (array.shape[1] // factor) * factor
            ]
        shape = (array.shape[0] // factor, factor, array.shape[1] // factor, factor)
        return array.reshape(shape).mean(axis=(-1, 1), dtype=numpy.float32)
    else:
        return array[::factor, ::factor]

Ideally it also gets geometry as input and it modifies it accordingly. MATLAB code also is useful.

AnderBiguri avatar Jun 30 '22 14:06 AnderBiguri