5
\$\begingroup\$

Let's say I was to change from RGB to HSV using a software like Matlab and then convert the result back to RGB using the same software. I know that there are going to be some slight noise and error in the colour values due to this conversion. Does anyone have any ideas on how one can preserve the colour values during such conversion or somehow reduce the noise or perhaps retrieve the loss in the colour data?

\$\endgroup\$

1 Answer 1

5
\$\begingroup\$

As someone who regularly works in other spaces (most frequently Lab) I'd say not to worry about it.

Since your rationale for going to another space is to make changes you're expecting that your RGB output will not be identical to your RGB input. Any noise should be well within acceptable boundaries.

HSV is by no means perfect and it could theoretically be an issue if you roundtrip between the two spaces a lot, but usually if you're doing that then there's a good chance something else is probably wrong in your workflow.

If you need extra accuracy then you can always increase the bit-depth before conversion, work in the higher accuracy and convert back after going back to RGB but realistically it's worth testing your RGB-HSV-RGB roundtrip a hundred times or so and see if you actually need to worry about the noise at all.

Depending on matlab's capabilities you could also set a threshold in the HSV-RGB conversion where if the pixel value is within a certain range of the original to pass back the original RGB value instead of the new one.

\$\endgroup\$
3
  • \$\begingroup\$ After doing 1 million roundtrips (with Python) I have no noticeable precision loss. \$\endgroup\$
    – Kel Solaar
    Aug 9, 2015 at 4:07
  • \$\begingroup\$ @KelSolaar Could you please share the piece of code using which you were doing the conversions? \$\endgroup\$ Mar 6, 2017 at 13:48
  • \$\begingroup\$ @SumitKumarSaha: Something along those lines: gist.github.com/KelSolaar/efe7bcd9ce0daa663280dc97814d83fb \$\endgroup\$
    – Kel Solaar
    Mar 7, 2017 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.