Skip to main content
Solved

How can I convert colorscheme from rgb to hsv for an aerial image (tif-file)


limo
Supporter
Forum|alt.badge.img+8
  • Supporter

Hi,

 

we have tiff files with rgb values. Is there an easy way to transform this tiff file in hsv color space?

Something like inside the transformer “rasterexpressionevaluator”?

 

thanks in advance

 

Best answer by hkingsbury

In the writer you can choose YCbCr as the colorspace, but not HSV


https://docs.safe.com/fme/2023.1/html/FME-Form-Documentation/FME-ReadersWriters/tiff/feature-types-w.htm

Could be worth submitting an idea to also specify HSV?

As @nielsgerrits suggests, python is probably going to be your best option here. There’s some helpful snippets on the subject of using PIL and Pillow here: https://stackoverflow.com/questions/22236956/rgb-to-hsv-via-pil-and-colorsys

View original
Did this help you find an answer to your question?

7 replies

nielsgerrits
VIP

I have not tried this, but on the FME HUB you can find a RasterHSVConverter which looks like does what you need.


nielsgerrits
VIP

Never tried this, but on the FME hub you can find the RasterHSVConverter.


nielsgerrits
VIP

Never tried it, but on the FME hub you can find the RasterHSVConverter which probably does what you need. For some reason safe won’t let me add a link to their own FME hub, but you can google it.


limo
Supporter
Forum|alt.badge.img+8
  • Author
  • Supporter
  • February 21, 2024

thanks for your hint @nielsgerrits . I tried it and it is generated a hsv color space of the tiff image.

But the values for saturation and value are sometime over 100%. I thing the values should be between 0 and 100%! Maybe the calculation inside the transformer is different?


nielsgerrits
VIP

I’m afraid I can not help you without diving into it. You can right click the transformer and choose edit to see what is inside. The computing is done using Python in a the PythonCaller.


hkingsbury
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • Best Answer
  • February 21, 2024

In the writer you can choose YCbCr as the colorspace, but not HSV


https://docs.safe.com/fme/2023.1/html/FME-Form-Documentation/FME-ReadersWriters/tiff/feature-types-w.htm

Could be worth submitting an idea to also specify HSV?

As @nielsgerrits suggests, python is probably going to be your best option here. There’s some helpful snippets on the subject of using PIL and Pillow here: https://stackoverflow.com/questions/22236956/rgb-to-hsv-via-pil-and-colorsys


limo
Supporter
Forum|alt.badge.img+8
  • Author
  • Supporter
  • February 22, 2024

Of course the option to specify hsv in the writer would be nice!

I think for raster data processing (pixel-based color segmentation) it is helpful to have hsv color space instead for rgb sometime!

 

 

I will try it out via python.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings