CERN / TIGRE

TIGRE: Tomographic Iterative GPU-based Reconstruction Toolbox
BSD 3-Clause "New" or "Revised" License
550 stars 182 forks source link

Add projection binning utility #381

Open AnderBiguri opened 2 years ago

AnderBiguri commented 2 years ago

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.