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

Laura & Edward Cannon cannon.el at gmail.com
Mon Aug 18 18:52:39 CEST 2008

color spaces
first off the data you got is not character data, it is python
integers, to get only 4 bits of significance try something like
int(floor(x/8.0)). padding could be accomplished by multiplication by
8. The answers to these would still be python integers, which would
still need to be encoded in the proper format, their might be a slick
way to do it, but look at the documentation for the ord() function.

2008/8/18 Ashish Sethi <ashishbitsgoa at gmail.com>:
> 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
> band(r,g,b).
> 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?
> _______________________________________________
> Image-SIG maillist  -  Image-SIG at python.org
> http://mail.python.org/mailman/listinfo/image-sig

More information about the Image-SIG mailing list