fastai icon indicating copy to clipboard operation
fastai copied to clipboard

Saturation Calls a RGB Grayscale Conversion in Logit Space

Open warner-benjamin opened this issue 1 year ago • 0 comments

The Saturation transform converts the input image to grayscale using RGB Luma 601-2 when the input image is already in logit space.

For an accurate conversion, the image would either need to be in RGB space or the grayscale method modified to be in logit space.

class _SaturationLogit():
def __call__(self, x):
    #interpolate between grayscale and original in-place
    gs = grayscale(x)
    gs.mul_(1-self.change[:,None,None,None])
    x.mul_(self.change[:,None,None,None])
    return x.add_(gs)

warner-benjamin avatar Mar 15 '23 23:03 warner-benjamin