Python Forum
how to compare two different size images in python and find corresponding pixel value - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: how to compare two different size images in python and find corresponding pixel value (/thread-24181.html)



how to compare two different size images in python and find corresponding pixel value - squidsirymchenry - Feb-03-2020

[I'm currently doing this project in which I have two similar images, however they are in slightly different angles. Think of it as shifting left, right, up, down, but not in the z-axis, only x and y-axis are changed. Is it possible to compare these images, and let's say I have a value in the first image (340,150), what methods can I use to find that pixel in the second image, and since the second image was shifted won't the pixel value shift as well? How do I solve this problem thanks! Huh Big Grin


RE: how to compare two different size images in python and find corresponding pixel value - michael1789 - Feb-03-2020

I'm not quite sure the problem. Are the images different sizes?

Is your example of (340, 150) the width and height of the image or x and y of where it is displayed? "Pixel Value" isn't a term I'm familiar with, however...

Have you used pygame? It has the image.get_rect() feature that will measure and image for you. You can then compare the width and height of the two images that way. You can also use the center of the image to locate it on the screen so that the two images will be in the same location regardless of size.