예제 #1
0
def bandreduction(bands: List[VIPSImage],
                  reduction: ChannelReduction) -> VIPSImage:
    if reduction == ChannelReduction.ADD:
        return VIPSImage.sum(bands).cast(bands[0].format)
    elif reduction == ChannelReduction.MAX:
        return Operation.call('bandrank', bands, index=len(bands) - 1)
    elif reduction == ChannelReduction.MIN:
        return Operation.call('bandrank', bands, index=0)
    elif reduction == ChannelReduction.MED:
        return Operation.call('bandrank', bands, index=-1)
    else:
        raise ValueError(f"{reduction} not implemented")
예제 #2
0
def bandjoin(bands: List[VIPSImage]) -> VIPSImage:
    if len(bands) == 1:
        return bands[0]

    return Operation.call('bandjoin', bands)