Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python
Re: Dominant color & PIL
 

Index | Next | Previous | View Flat


fredrik at pythonware

Jan 24, 2006, 5:44 AM


Views: 859
Permalink
Re: Dominant color & PIL [In reply to]

Sebastjan Trepca wrote:

> I was wondering is it possible to find out which colour is dominant in an
> image using PIL?
> It would be very easy to create interesting mozaic images with that :)

some alternatives:

>>> i = Image.open(...)

>>> i.quantize(1).convert("RGB").getpixel((0, 0))
(208, 205, 202)

>>> import ImageStat
>>> s = ImageStat.Stat(i)
>>> s.mean
[208.32295432458699, 204.56614188532555, 202.44663427275671]

>>> i.resize((1, 1), Image.ANTIALIAS).getpixel((0,0))
(212, 212, 210)

(quantize will only return colors that actually exist, the other two
uses different ways to calculate some kind of average color)

</F>



--
http://mail.python.org/mailman/listinfo/python-list

Subject User Time
Dominant color & PIL trepca at gmail Jan 22, 2006, 12:07 PM
    Re: Dominant color & PIL hancock at anansispaceworks Jan 22, 2006, 8:22 PM
    Re: Dominant color & PIL w.damen at gmail Jan 23, 2006, 5:47 AM
    Re: Dominant color & PIL hancock at anansispaceworks Jan 23, 2006, 7:12 AM
        Re: Dominant color & PIL trepca at gmail Jan 23, 2006, 10:36 AM
    Re: Dominant color & PIL fredrik at pythonware Jan 24, 2006, 5:44 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.