You Are Here:

Community: Developer Discussion Boards

#1 Old Compare 2 image - 2007-02-01, 20:15

Join Date: Jan 2007
Posts: 8
dany88a
Offline
Registered User
I try with this, but no work, can help me?

Code:
def Compare(im,im2):
    width, height = im.size #same widht\height for im and im2
    for y in height:
        for x in width:
            pixel1= im.getpixel(x, y)
            pixel2= im2.getpixel(x, y)
            if pixel1 != pixel2:
                pixelvarious=pixelvarious+1
    if pixelvarious > 100:
         return 0
Last edited by dany88a : 2007-02-01 at 22:31.
Reply With Quote

#2 Old Re: Compare 2 image - 2007-02-01, 21:01

Join Date: Jan 2007
Posts: 80
federico2929
Offline
Regular Contributor
Are they supposed to be the exact same images? because even if its just two images taken one after another of the same thing, from the same place, with no difference because of the level of noise in the image they wont be the same. What you will probable want to do is give them a percentage of error you allow. I think its better if you dont work in RBG but instead in HSV Hue, Saturation, Value (Brightness) http://en.wikipedia.org/wiki/HSV_color_space, there should be an easy transformation from one type to the other. This is helpfull because you can leave the Hue with a very small deviation and give room for change in Brightness and saturation

Let me know if this helpts
Reply With Quote

#3 Old Re: Compare 2 image - 2007-02-01, 21:51

Join Date: Jan 2007
Posts: 8
dany88a
Offline
Registered User
mmm, i use the same image (not camera, with the conseguent little difference) i hope that anyone can adjust the code...
Reply With Quote

#4 Old Re: Compare 2 image - 2007-02-01, 22:10

Join Date: May 2006
Posts: 622
Location: Oulu, Finland
lfd
Offline
Super Contributor
Hi dany88a,

What you exactly want to compare? Heigh, width, resolution, size on the disk...?

Please try to explain better what you want.

Also when you post some source code, please use the code tage (#button) instead of putting dots.

LFD


Devices:
Nokia E61 3rd Edition - pys60 1.4.0

Tips and modules:
http://www.lfdm.net/thesis
Reply With Quote

#5 Old Re: Compare 2 image - 2007-02-01, 22:29

Join Date: Jan 2007
Posts: 8
dany88a
Offline
Registered User
as you can see on the source, i want to compare pixel,
Reply With Quote

#6 Old Re: Compare 2 image - 2007-02-02, 12:23

Join Date: May 2006
Posts: 622
Location: Oulu, Finland
lfd
Offline
Super Contributor
Ok here you go.
Check the following code, it works for me

Code:
from graphics import Image

def Compare(im,im2):
    width, height = im.size #same widht\height for im and im2
    pixelvarious = 0
    x = 0
    y = 0
    for y in range( height ):
        for x in range( width ):
            pixel1= im.getpixel( (x, y) )
            pixel2= im2.getpixel( (x, y) )
            if pixel1 != pixel2:
                pixelvarious = pixelvarious + 1
            if pixelvarious > 100:
                print "pixelvarious: ", pixelvarious
                return False
    print "pixelvarious: ", pixelvarious
    return True


if __name__ == "__main__":

    image1 = Image.open('C:\\Images\\viewfinder1.png')
    image2 = Image.open('C:\\Images\\viewfinder.png')

    if( Compare(image1, image2)):
        print "Same or almost"
    else:
        print "Images are different"
LFD


Devices:
Nokia E61 3rd Edition - pys60 1.4.0

Tips and modules:
http://www.lfdm.net/thesis
Reply With Quote

#7 Old Re: Compare 2 image - 2007-02-02, 21:22

Join Date: Jan 2007
Posts: 8
dany88a
Offline
Registered User
mmm.....yes, work also the code posted by me......thx
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
--- ???save image problem??? --- ferenn Mobile Java Media (Graphics & Sounds) 6 2007-10-01 15:33
Opening a JPEG Image ummarbhutta Mobile Java Media (Graphics & Sounds) 8 2007-02-15 07:34
how to cut some part of Image mshouab Mobile Java Media (Graphics & Sounds) 2 2006-08-04 10:05
HELP: Mutable Image to Immutable Image? rj_cybersilver Mobile Java Media (Graphics & Sounds) 1 2005-03-26 10:58
Nokia Image Converter davidpurdie General Discussion 0 2004-02-18 16:31

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