You Are Here:

Community: Developer Discussion Boards

#1 Old Lightbulb getpixel and image processing - 2005-09-04, 21:04

Join Date: Jan 2005
Posts: 148
Location: Bangkok, Thailand
Send a message via MSN to korakotc
korakotc's Avatar
korakotc
Offline
Regular Contributor
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
See more detail here.
http://www.bigbold.com/snippets/posts/show/632
Reply With Quote

#2 Old Cool Re: getpixel and image processing - 2005-09-05, 15:20

Join Date: Jan 2005
Posts: 148
Location: Bangkok, Thailand
Send a message via MSN to korakotc
korakotc's Avatar
korakotc
Offline
Regular Contributor
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
Reply With Quote

#3 Old Re: getpixel and image processing - 2005-09-05, 17:53

Join Date: Dec 2004
Posts: 646
jplauril's Avatar
jplauril
Offline
Forum Nokia Expert
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.
Reply With Quote

#4 Old Re: getpixel and image processing - 2005-09-06, 05:26

Join Date: Jan 2005
Posts: 148
Location: Bangkok, Thailand
Send a message via MSN to korakotc
korakotc's Avatar
korakotc
Offline
Regular Contributor
One use case for this is to create a mask automatically from image.
Code:
mask = automask(im, transparent=0xffffff)
c.blit(im, mask=mask)
You implement automask by
- 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.
Reply With Quote

#5 Old Re: getpixel and image processing - 2005-09-07, 09:45

Join Date: Jan 2005
Posts: 148
Location: Bangkok, Thailand
Send a message via MSN to korakotc
korakotc's Avatar
korakotc
Offline
Regular Contributor
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.
Reply With Quote

#6 Old Re: getpixel and image processing - 2006-02-09, 08:51

Join Date: Jan 2005
Posts: 148
Location: Bangkok, Thailand
Send a message via MSN to korakotc
korakotc's Avatar
korakotc
Offline
Regular Contributor
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
Reply With Quote

#7 Old Thumbs up Re: getpixel and image processing - 2006-07-03, 09:04

Join Date: Jul 2006
Posts: 2
tufat123
Offline
Registered User
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia