This repository implement pytorch Tensor color space conversion from rgb to hsv/hsl and backwards.
-
The conversion process is differentiable in a natural way, but since the mapping from RGB to HSV/HSL space is not continuous in some place, it may not be a good idea to perform back propagation.
-
The code was written to accept only image like tensors
tensor.shape == [B x 3 x H x W]
, but it's easy to modify the code to accept other shapes. -
Reference is in here
example usage can be find in test.py
.
Before using the function, please make sure that:
- The input/output rbg/hsv/hsl tensors should all be normalized to 0~1 for each channel
- The rgb format is RGB instead of BGR
- The shape of the tensor match the requirement