1

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

  1. Mapping object image in scene image using SIFT feature detector and FlannBasedMatcher

  2. 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.

  1. 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)

    Object Image Mask

    sceneImageMask = np.zeros(perspectiveFixedImage.shape[:2], dtype=perspectiveFixedImage.dtype)

    sceneImageMask = cv2.compare(perspectiveFixedImage, 150, cv2.CMP_LT)

    Scene Image Mask

    subtractedImage = dilatedObjectImage - sceneImageMask

    Subtracted Image

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.

d32
  • 53
  • 1
  • 6
  • You're probably overthinking this. Once you have fixed the perspective of the input image, simply find the two grids, and check which circle is filled. There's no need to exactly overlap with the original "exam" image to find out the final vote. – Miki Aug 07 '15 at 09:38
  • you are correct but this is the one type of sheet, there will be sheets with no circles and grid, and to find the contours created by user we need to remove contours that are present in the master sheet(sheet with no user input) – d32 Aug 10 '15 at 04:36

0 Answers0