Computing Hue from RGB color space

Can we compute hue from an RGB tensor in a differentiable way?

My model is n RGB color space and I want to write a loss function to minimise the difference in hue component in the input image and the image generated by the model.

Hue Loss = |Hue Input - Hue output|

Thank you

You can find the transformation from RGB to HSV in this post. It looks like it should be differentiable, but let me know, if you run into any trouble implementing it.

Hi, @ptrblck @anjali-chadha ,I’m confused that why you emphasized that

It looks like it should be differentiable

i also saw that some others emphasized that differentiable
as far as i know, rgb image tensor range [0,1], and hsv image tensor also range [0,1], if rgb is always differnetiable, why hsv not.
Thank you!

I’m not sure I understand the question completely, but I was pointing out that the transformation should be differentiable (I haven’t written and confirmed it), not the tensors in isolation.

sorry for my bad expression, what my question is that:
what is the differences between rgb color space image and hsv color space image when calculating differentiation
or could you give me a hsv color space image example/case that it is non-differentiable.
thank you!

I’m not claiming any operations with input images in a specific color space might or might not be differentiable. In my post I was pointing out that the RGB to HSV transformation (only this operation) seems to be differentiable.

I got it, thank you very much, for the detailed interpretation