PIL and antialiasing problem

  • Thread starter Laszlo Zsolt Nagy
  • Start date
L

Laszlo Zsolt Nagy

Hi all,

I have a little problem with PIL. I need to display images in a
browser (thumbnails) (this is the selector window).
I also need the original version of the image to be displayed in a
Java applet.

One example:

thumbnail: http://designasign.biz/applet/GIF_Small/AIRCRAFT/a10per.png
original: http://designasign.biz/applet/GIF/AIRCRAFT/a10per.png

I made the thumbnail from the original image using PIL this way:


im = Image.open(fullpath)
try:
im.thumbnail(THUMBSIZE,Image.ANTIALIAS)
im.save(thumbpath)
finally:
del im


If I do not use ANTIALIAS, then I get this:

http://designasign.biz/tmp/a10per.png

With the ANTIALIAS-ed version, the problem is that you cannot see the
lines - they are very light gray, almost invisible. I have many cliparts
with thin lines. However, I also have many cliparts like this:

http://designasign.biz/applet/GIF/AFRICA/angel03.png

I tried to posterize or darken the images but I could not find a good
solution. (I also tried to count the number of colors in the image and
use this info.) Can you suggest an image filter and/or method that creates
darker black lines from the original thin lines? Also it would be
great to have it working with those colorful smudged images. It will
be terribly slow to separate them by hand. There are almost 15000 of
them...

--
Thanks,
Laszlo

mailto:[email protected]
web: http://designasign.biz
 
W

Will McGugan

Laszlo said:
I tried to posterize or darken the images but I could not find a good
solution. (I also tried to count the number of colors in the image and
use this info.) Can you suggest an image filter and/or method that creates
darker black lines from the original thin lines? Also it would be
great to have it working with those colorful smudged images. It will
be terribly slow to separate them by hand. There are almost 15000 of
them...

Try running ImageFilter.MinFilter on the image before you thumbnail it.
This should make dark lines thicker.

HTH,

Will McGugan
 
L

Laszlo Zsolt Nagy

Try running ImageFilter.MinFilter on the image before you thumbnail it.
This should make dark lines thicker.
HTH,
Will McGugan

You are my man! It worked perfectly!

Statement: Sometimes PIL is better than Adobe Photoshop. :)

I also found these with the aid of the wonderful dir() function:

MinFilter, MaxFilter, MedianFilter, ModeFilter, RankFilter, BuiltInFilter

They do not have a docstring and they are not documented in the
handbook. I'm curious what they do exactly. The others (like BLUR, EMBOSS,
CONTOUR etc.) are documented very well. I wonder why is that.


Python forever,

Laszlo

mailto:[email protected]
web:http://designasign.biz
 
W

Will McGugan

Laszlo said:
You are my man! It worked perfectly!

Statement: Sometimes PIL is better than Adobe Photoshop. :)

Happy to help :)
I also found these with the aid of the wonderful dir() function:

MinFilter, MaxFilter, MedianFilter, ModeFilter, RankFilter, BuiltInFilter

MinFilter replaces each pixel with the darkest pixel within the filter
area. MaxFilter replaces each pixel with the brightest of the
surrounding pixels. MedianFilter sorts the surrounding pixels by
brightness and selects the middle value. I think ModeFilter selects the
most common pixel if occurs more than a certain threshhold. RankFilter
is like Median, but it selects the colour at a specific point within the
ordered list. Not sure about BuiltInFilter, my guess is its an
implementation detail of some kind..


Regards,

Will McGugan
 
F

Fredrik Lundh

Laszlo said:
Statement: Sometimes PIL is better than Adobe Photoshop. :)

I also found these with the aid of the wonderful dir() function:

MinFilter, MaxFilter, MedianFilter, ModeFilter, RankFilter, BuiltInFilter

They do not have a docstring and they are not documented in the
handbook. I'm curious what they do exactly. The others (like BLUR, EMBOSS,
CONTOUR etc.) are documented very well. I wonder why is that.

they were experimental (and some of them were slightly broken, iirc)
in 1.1.4. they're all officially supported in 1.1.5:

http://www.pythonware.com/library/pil/handbook/imagefilter.htm

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top