Good evening,

F
irstly, thanks for creating and maintaining such a fantastic library, the
PIL is awesome!

I've got an interesting problem and I'd really appreciate if someone could
point me in the right direction. I'm a reasonable developer but I've become
out of my depth in image science :)

I've got greyscale images which I have dithered (Floyd-Steinberg) so that
they contain exactly 8 shades. The pixel values present in the images are 0,
36, 73, 109, 146, 182, 219, 255 - so 8 levels with pure-white and
pure-black being represented. Naturally, most of the 256 possible pixel
values in the histogram are empty.

I want to reduce the size of this image by 3x in both directions, ie (300,
300) => (100, 100) *with* anti-aliasing but *without* creating pixels
outside of those 8 shades. Of course, the Lanczos implementation in PIL
doesn't know to only use values 0, 36, 73 etc, so it uses the full 256
range, thereby undoing my dithering work.

Can anyone suggest a good approach to this? Would it be possible to modify
the resampling algorithm to work in 8 shades rather than 256? Or is there a
way I could put the pixel values back into the 8 "buckets" afterwards
without wrecking the colour accuracy? I have tried the latter and gradients
become steps, as you'd expect. It doesn't seem right to apply dithering
again somehow.

I have considered re-ordering my process from:
*High-res image -> Dithering -> Resampling*

to

*High-res image -> Resampling -> Dithering*

but I then think the dithering process wreaks havoc on the beautifully
antialiased edges in the image.

Any thoughts would be very gratefully received.

Kind regards,
Paul
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to