| Reply | « Previous Thread | Next Thread » |
|
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.
|
|
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 |
| federico2929 |
| View Public Profile |
| Find all posts by federico2929 |
|
mmm, i use the same image (not camera, with the conseguent little difference) i hope that anyone can adjust the code...
|
|
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 |
|
as you can see on the source, i want to compare pixel,
|
|
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"
Devices: Nokia E61 3rd Edition - pys60 1.4.0 Tips and modules: http://www.lfdm.net/thesis |
|
mmm.....yes, work also the code posted by me......thx
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| 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 |