| Reply | « Previous Thread | Next Thread » |
|
Python may be a bit too slow for image processing.
Moreover, you can't read the color value of an image (or canvas) with the current API. So, here's a shortcut library that give you 'getpixel(x,y)' function http://larndham.net/service/pys60/getpixel.py Code:
# im is an image object import getpixel getpixel.enable(im) # attach getpixel to Image class r, g, b = im.getpixel(0,0) # top left corner http://www.bigbold.com/snippets/posts/show/632 |
|
Here's the first script that does the simplest image processing.
It detects motion by summing pixel difference. Only the hot spot (30x30) zone is evaluated, so it's not too slow. http://www.bigbold.com/snippets/posts/show/636 I got the idea from here. (with screenshots) http://gumuz.looze.net/wordpress/ind...ion-detection/
Last edited by korakotc : 2005-09-05 at 15:22.
Reason: adding a link
|
|
Okay, okay, I'm convinced
![]() The next release will have a native getpixel method so hopefully there will be no need to resort to these horrible hacks anymore. |
|
One use case for this is to create a mask automatically from image.
Code:
mask = automask(im, transparent=0xffffff) c.blit(im, mask=mask) - mask = Image.new with black and white - loop for all pixel, if equal transparent, point() it on mask - return mask Pretty useful to create Sprite. transparent can even be default to top-left corner. |
|
Another use case is to find the boundary box of a text() on Canvas.
Not elegant though, it would be better to get the native support for text() boundary. |
|
I have just written the automask functionality (necessary for Sprite).
Code:
def automask(im):
width, height = im.size
mask = Image.new(im.size, '1')
tran = im.getpixel((0,0))[0]
for y in range(height):
line = im.getpixel([(x, y) for x in range(width)])
for x in range(width):
if line[x] == tran:
mask.point((x,y), 0)
return mask
|
|
Hi.. Why dont u try GPix Pixel Ad Script from
http://tufat.com/s_milliondollarhomepage.htm? As far as I Know, its good! Would that be of some help? -TufatUser |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Using Icon as Image | korakotc | Python | 6 | 2006-02-13 20:34 |
| Isn't there a GetPixel() ??? | edi678 | Mobile Java General | 4 | 2005-03-28 22:00 |
| How can I zoom in my image using getpixel? | badzoy | Mobile Java Media (Graphics & Sounds) | 0 | 2004-01-07 04:10 |