I need to find image (object image) from a scene image and subtract them to remove all contours present in object image.
Here is what I am doing:
Object image: image created programmatically object image
Scene Image: photo of printed copy of object image captured using mobile camera scene image
Mapping object image in scene image using
SIFT
feature detector andFlannBasedMatcher
fixing perspective image after fixing perspective
At this stage I am able to find object image and fix it perspective but the problem is coordinates of contours (circles and text) is bit different from that of object image.
Any suggestions/advice so that coordinates in perspective fixed image matches with that of object image.
creating masks and subtract the image
objectImageMask = np.zeros(objectImage.shape[:2], dtype=objectImage.dtype)
objectImageMask = cv2.compare(objectImage, 150, cv2.CMP_LT)
dilatedObjectImage = cv2.dilate(objectImageMask , np.ones((0, 0), 'uint8'), iterations = 1)
sceneImageMask = np.zeros(perspectiveFixedImage.shape[:2], dtype=perspectiveFixedImage.dtype)
sceneImageMask = cv2.compare(perspectiveFixedImage, 150, cv2.CMP_LT)
subtractedImage = dilatedObjectImage - sceneImageMask
Image may or may not have border.
Please find source code here. Source Code: find and subtract image
Please advice/suggest how image subtraction handling mismatch in contour/text coordinates can be achieved.