简体   繁体   中英

Extract part of image

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.

在此处输入图像描述

在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM