I am struggling with a few concepts around colorspace, and profiles etc.
I have implemented a transformations that relies on a linear RGB input. (An inversion of a negative film scan)
The output from this transformation is to be further processed by other tools, ideally Rawtherapee.
Rawtherapee internal working space is linear RGB, and supposed to use ProPhoto. I expect to use Rawtherapee to output sRGB files.
My question is should my transformation be converted from RGB to sRGB, If It's assumed that the my output is to further processed in linear RGB?
i.e. is the converion from RGB to sRGB back to RGB and finally back to sRGB lossless?
Colorspace When to convert?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Colorspace When to convert?
It would not be lossless, if the image is jpg. Each read and write in ImageMagick will produce some losses due the lossy jpg compression. Other formats such as PNG or TIFF (not JPG compress) should have no loss.
If you want to be exact, perhaps try a linear RGB profile, rather than just -colorspace RGB. In particular, I do not think IM has a conversion to ProPhoto colorspace (https://en.wikipedia.org/wiki/ProPhoto_RGB_color_space). But if there is a Prophoto profile, you could/should use that.
Also note that SRGB and RGB were swapped in older versions of ImageMagick. So please always provide your IM version and platform when asking questions on this forum.
If you want to be exact, perhaps try a linear RGB profile, rather than just -colorspace RGB. In particular, I do not think IM has a conversion to ProPhoto colorspace (https://en.wikipedia.org/wiki/ProPhoto_RGB_color_space). But if there is a Prophoto profile, you could/should use that.
Also note that SRGB and RGB were swapped in older versions of ImageMagick. So please always provide your IM version and platform when asking questions on this forum.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Colorspace When to convert?
Most of the color conversions are in gem.c. But I do not see RGB to sRGB there. So one of the developers or other software knowledgeable people would have to answer that.
But see https://en.wikipedia.org/wiki/SRGB
But see https://en.wikipedia.org/wiki/SRGB
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Colorspace When to convert?
For a summary of RGB<=>sRGB, see https://en.wikipedia.org/wiki/SRGB#The_ ... amma.22.29 .
Converting between RGB and sRGB is lossless, except that arithmetical precision isn't infinite, so expect an error of about 0.5*2^-16 in Q16 non-HDRI, etc. The code is in colorspace.c and pixel.c.
ProPhoto profiles are available. ProPhoto has a larger gamut than sRGB, so conversion from ProPhoto to sRGB may be lossy, depending on the "-intent" mode of the profile conversion.
As Fred says, saving to JPEG is lossy. Don't use JPEG as an intermediate format.
Converting between RGB and sRGB is lossless, except that arithmetical precision isn't infinite, so expect an error of about 0.5*2^-16 in Q16 non-HDRI, etc. The code is in colorspace.c and pixel.c.
ProPhoto profiles are available. ProPhoto has a larger gamut than sRGB, so conversion from ProPhoto to sRGB may be lossy, depending on the "-intent" mode of the profile conversion.
As Fred says, saving to JPEG is lossy. Don't use JPEG as an intermediate format.
snibgo's IM pages: im.snibgo.com
Re: Colorspace When to convert?
Thanks,
Am I correct in my understanding that converting wider gammut colorspace like ProPhoto --> sRGB is losefull?
i.e. Profoto --> sRGB --> Profoto will result in some clipping if the original colours are "wider" than what can be translated into sRGB space.
Am I correct in my understanding that converting wider gammut colorspace like ProPhoto --> sRGB is losefull?
i.e. Profoto --> sRGB --> Profoto will result in some clipping if the original colours are "wider" than what can be translated into sRGB space.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Colorspace When to convert?
It depends on the "-intent" setting. I suppose "-intent relative" would give lossless ProPhoto => sRGB => ProPhoto, provided the profiles support that mode, but I haven't checked.
snibgo's IM pages: im.snibgo.com