Reputation:
I need to merge two images with respect to its coordinate values.
I have done merging using single point to point merge using Paste an image to another image at two given co-ordinates with altered opacity using PIL or OpenCV in Python
I got output for that. But I need to do multiple coordinate comparison and merge in same 2 images.. Is there any possible way to do that?
Above images are the results. Output has only single point to point merge. But I need in multiple point merge.
The parameters are {"Headpts": [354,64, "ShoulderSpinepts": [25,234], "LeftShoulderpts": [123,243], "LeftElbowpts": [54,234], "LeftHandpts": [0, 0], "RightShoulderpts": [0, 0], "RightElbowpts": [0, 0], "RightHandpts": [0, 0], "MidSpinepts": [0, 0], "BaseSpinepts": [0, 0], "LeftHippts": [0, 0], "LeftKneepts": [0, 0], "LeftFootpts": [0, 0], "RightHippts": [0, 0], "RightKneepts": [0, 0], "RightFootpts": [0, 0], "LeftWristpts": [0, 0], "RightWristpts": [0, 0], "Neckpts": [0, 0]}
Upvotes: 3
Views: 550
Reputation: 241
I'm using cv2.getAffineTransform()
. Because it can only add three point (only four on cv2.getPerspectiveTransform()
), so I cut the image to multiple triangle.
This is my sample:
And my goal is to reshape the cat's head in to a 300*300 box.
First, crop the area into triangle according the point.
And then usingcv2.getAffineTransform()
to get those specific area which had been adjusted.
Then use cv2.bitwise_or()
to add them together. Generated image:
Your project is more complex, but it's the same theory. You need crop the image into several triangle . And then transform them to fit the model. After merge those triangle together, you can get your image.
Upvotes: 2