RGB_HSV_HSL
RGB_HSV_HSL copied to clipboard
a pure pytorch implementation of color space conversion, including rgb2hsl, rgb2hsv, hsv2rgb, hsl2rgb
Pure Pytorch implementation of RGB to HSV/HSL conversion
This repository implement pytorch Tensor color space conversion from rgb to hsv/hsl and backwards.
Notes
-
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
Usage
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