I need to do a modulo transform on each value of an image that is stored as a tensor
. For an image stored in PIL format, this can be done on the red channel using:
Cr = 50; maxV = 255
red, green, blue = img.split()
red = red.point(lambda p: (p+Cr) % max_V)
Not sure if there is a way to do the same in torch
, without converting the image back to PIL
and forth to torch tensor
. The problem is that the tensor
values are float and usually have -ve and +ve values. I can assume, for example, that maxV = 1
and Cr = 0.2
.