1

I want to extract the images inside the photo frames. For the first image I want to extract the deer, car, plane and boat. For the second image I want to extract the bird. I am using openCV in python, but this is new to me.

I have started with transforming the images into greyscale and the using the edge detector cv2.Canny(), but from here I don't really know how to continue, any tips? Would also really appreciate some code / pseudocode.

enter image description here

enter image description here

Kimmen
  • 183
  • 1
  • 1
  • 8

1 Answers1

2

Python/OpenCV cv2.matchTemplate can ignore parts of the image when doing the template matching by using a mask image. In your case, you need a mask that is white for the frame and black inside. It only allows the mask for certain comparison metrics. See the documentation at https://docs.opencv.org/4.1.1/df/dfb/group__imgproc__object.html#ga586ebfb0a7fb604b35a23d85391329be

An example is at How to template match a simple 2D shape in OpenCV?

Another simpler example is at cv2.matchTemplate finds wrong template in image

fmw42
  • 46,825
  • 10
  • 62
  • 80