[Image-SIG] RGB[8:8:8] to RGB[4:4:4] and RGB[12:12:12]

Ashish Sethi ashishbitsgoa at gmail.com
Mon Aug 18 12:33:08 CEST 2008

Hey all,

I am newbie to image processing using python

I have a problem in converting between different RGB color spaces.I have a
jpeg file in rgb mode.
The rgb data by default is in RGB[8:8:8] mode...i.e, 8 bits(1 byte) per
I need to convert it into RGB[4:4:4] format by getting the rgb information
of each pixel in the image
and converting the ascii values obtained for the R,G and B bands into binary
form and then clip the least significant 4 bits
from this binary no. to form a 4 bit binary value and then convert this back
to ascii and and save the new information back
to the image file. Untill now, I have been able obtain the pixel information
of my image file using :
>*   >>> im = Image.open("image.jpg")
*>*   >>> pix = im.load()
*>*   >>> pix[0, 0]
*>*   (226, 162, 125)
1.Now, how do i convert this ascii data to binary?
2.how do i mask last 4 bits ( least significant bits )?
3.also, I need to convert the same image to RGB[12:12:12] mode,for which i
need to zero pad with 4 zeroes the
binary RGB[8:8:8] data. How do I do this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20080818/65107719/attachment.htm>

More information about the Image-SIG mailing list