[Image-SIG] flatten 1 bit images
Matthew Nuzum
newz at bearfruit.org
Wed May 16 16:43:41 CEST 2007
On 5/15/07, Joancarles CasasÃn <joanca at casasin.com> wrote:
> I'd like to flatten four 1 bit images in a resulting one, having
> white as transparent an all black pixels in the separated images
> visible. I can't do it directly.
> Do I need to make any conversion before? is this possible?
Sorry, I'm not expert in imaging, but just wanted to say that your job
sounds like a simple case of boolean math.
1100000011
| 1000011110
===========
1100011111
So even if you're not able to do this in pil, if you can convert your
image to an array of bits, you can then OR them together to get the
resulting output.
I've only done this in C and asm, but it's literally the simplest type
of math for CPUs to do.
...
just doing a little testing, I've never dealt with binary in python...
Looks like the normal stuff works. Since:
9 == 1001b
8 == 1000b
1 == 0001b
then:
>>> 9 & 1
1
>>> 8 | 1
9
--
Matthew Nuzum
www.bearfruit.org
newz2000 on freenode
More information about the Image-SIG
mailing list