[Lcms-user] Question re Preservation of Alpha Channel in Grayscale to Color Transform
An ICC-based CMM for color management
                
                Brought to you by:
                
                    mm2
                    
                
            
            
        
        
        
    | 
      
      
      From: Noel C. <NCa...@Pr...> - 2016-06-27 00:38:53
      
     | 
| Hi Marti and all, We have a case where we have a grayscale image expressed as 4 values per pixel, the first three are channels, identical to one another, representing the grayscale value, while the fourth is Alpha. You could describe this as GGGA. The image has a grayscale profile. We would like to transform and copy that image into an RGBA color image with a color profile. The output RGBA buffer uses the predefined types TYPE_RGBA_8, TYPE_RGBA_16, or TYPE_RGBA_FLT. Before LCMS 2.8, we expressed the input grayscale image as follows: #define TYPE_GxxA_8 (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(3)|CHANNELS_SH(1)|BYTES_SH(1)) #define TYPE_GxxA_16 (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(3)|CHANNELS_SH(1)|BYTES_SH(2)) #define TYPE_GxxA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|EXTRA_SH(3)|CHANNELS_SH(1)|BYTES_SH( 4)) This all worked fine except of course the A value was not copied. We had a routine that would copy the A values separately. Now we'd like to use the new 2.8 preserve extra channel feature, but the LCMS 2.8 won't copy the A value because the number of extra channels from the grayscale input (3) doesn't match the number for the color output (1). Our first obvious idea was to define and use these for the grayscale image: #define TYPE_GGGA_8 (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)) #define TYPE_GGGA_16 (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)) #define TYPE_GGGA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH( 4)) This seems to work fine with LCMS 2.8, and now copies the A across since there's just the one extra A channel in both input and output formats. However, my questions are these, since grayscale images don't normally have 3 channels of data... Is this valid? Since it's a grayscale image does LCMS use all three values or just the first one? Do we pay a performance penalty for asking LCMS to transform 3 channels that are all exactly the same? Thanks in advance for sharing your wisdom. -Noel |