Hi everyone,
 
I wanted to share with everyone a solution to an interesting Lab color space problem that I discovered empirically, but cannot explain why it works.
 
The Lab color space consists of three values: L, *a, and *b. L controls the intensity of a color, and (a, b) its hue. The range of L is 0 to 255 and (a, b) -128 to 127.
 
The trio (0xA0, 0, 0) should produce a gray color, however a 2x2 image defined below produces some sort of cyan hue:
 
4 0 obj
<</Type /XObject
/Subtype /Image
/Width 2
/Height 2
/ColorSpace [/Lab <</WhitePoint [1 1 1]
/Range [-128 127 -128 127]
>>]
/BitsPerComponent 8
>>
stream
0xA0 0 0
0xA0 0 0
0xA0 0 0
0xA0 0 0
endstream
endobj

Through trial and error, I discovered that the *a and *b values have to be XOR'ed with 0x80, and then it works fine. I tested it on a large number of Lab tiffs. Here is a code fragment to do the job:
 
  for( int i = 0; i < m_pImageObj->m_objStream.m_nCurrentSize / 3; i++ )
  {
   m_pImageObj->m_objStream.m_pBuffer[i * 3 + 1] ^= 0x80;
   m_pImageObj->m_objStream.m_pBuffer[i * 3 + 2] ^= 0x80;
  }
 
If someone could offer an explanation why this works, I would appreciated it very much.
 
(BTW My experiments show that the WhitePoint parameter does not affect anything).
 
Peter Persits
Persits Software, Inc.
http://www.persits.com
 

Reply via email to