João
João

Reputation: 185

how to reposition one binary image based on another? opencv-python

I have images like these: enter image description here

enter image description here

And I want to reposition one based on the other position, could be in a way where the number of white pixels intersection is as big as possible. is that even possible?

Upvotes: 1

Views: 386

Answers (1)

Samuel Nathanson
Samuel Nathanson

Reputation: 11

Assuming the two images are of the same object:

Let us call the top image Image A, and let us call the bottom image Image B. If these two images were taken of the same object, we could define a transformation from image A to B using a projective transformation. This would be a 3x3 matrix on the lefthand side multiplied by the coordinates of image A (x,y) on the right hand side.

What you need to do is find the transformation A that makes A*ImageA = Image B

You can find more information on affine and projective transformations here: https://www.graphicsmill.com/docs/gm5/Transformations.htm

Upvotes: 1

Related Questions