Round-trip ICC conversion
Posted: 2013-01-08T17:30:03-07:00
Hopefully this will be an interesting one...
We have an image in CMYK (with ICC profile), with a limited number of colours having special, fixed values in each of the 4 channels, (e.g. C=0%, M=0%, Y=100%, K=100% as well as C=100%, M=100%, Y=100%, K=100%). We need to be able to convert this to sRGB and then back again (after a little processing that requires sRGB*) so that the final CMYK image will contain exactly the same colours.
For example: ordinarily the CMYK colour for something funky like (Q16 here) cmyk(65535,65535,0,65535) converts to srgb(100,0,0) then back to cmyk(47364,44355,44035,56149). We would like a way of getting it to convert back to cmyk(65535,65535,0,65535).
Given we have only a few colours in the original CMYK image, my naive, brute force approach was to create a lookup table in C++ that will store key/value pairs for each of the colours (srgb(100,0,0) being a key with value cmyk(65535,65535,0,65535) in the example above), then iterate over the sRGB image's pixels replacing the keys with their values from the lookup table.
Is there a better way to achieve what we want? If not, are there any wizards that could offer some guidance in coding up my above approach in an IM compliant way (ideally leveraging multiple cores, and implementing IM's progress reporting pattern)?
Any input greatly appreciated.
*the processing won't introduce any new colours into the image
We have an image in CMYK (with ICC profile), with a limited number of colours having special, fixed values in each of the 4 channels, (e.g. C=0%, M=0%, Y=100%, K=100% as well as C=100%, M=100%, Y=100%, K=100%). We need to be able to convert this to sRGB and then back again (after a little processing that requires sRGB*) so that the final CMYK image will contain exactly the same colours.
For example: ordinarily the CMYK colour for something funky like (Q16 here) cmyk(65535,65535,0,65535) converts to srgb(100,0,0) then back to cmyk(47364,44355,44035,56149). We would like a way of getting it to convert back to cmyk(65535,65535,0,65535).
Given we have only a few colours in the original CMYK image, my naive, brute force approach was to create a lookup table in C++ that will store key/value pairs for each of the colours (srgb(100,0,0) being a key with value cmyk(65535,65535,0,65535) in the example above), then iterate over the sRGB image's pixels replacing the keys with their values from the lookup table.
Is there a better way to achieve what we want? If not, are there any wizards that could offer some guidance in coding up my above approach in an IM compliant way (ideally leveraging multiple cores, and implementing IM's progress reporting pattern)?
Any input greatly appreciated.
*the processing won't introduce any new colours into the image