Feature Extraction - How to ONLY Detect SIFT Feautures OUTSIDE Region of Interest?

308 Views Asked by At

I understand that it is possible to exclusively extract features INSIDE a ROI by providing a mask to the sift feature detector. I am wondering if it is possible to exclusively extract SIFT features OUTSIDE the ROI instead?

From my understanding, when you create a mask, you are filling the original image with zeros, with the size of original image

mask = np.zeros(img.shape[:2], dtype=np.uint8)

and then you must draw your selected ROI on the mask image, to specify the area you want the sift detector to focus on

cv2.rectangle(mask, (50,50), (150,150), (255), thickness = -1)

From here you could detect and draw the keypoints INSIDE the ROI of your image

kp = sift.detect(gray,mask) #passing mask here so sift only looks for keypoints within your ROI

I am trying to use this knowledge to only detect features outside my ROI, but have had no success. What is the best way to approach this?

1

There are 1 best solutions below

0
Mana Amini On

you can change the mask like this

mask = np.ones(img.shape[:2], dtype=np.uint8)
cv2.rectangle(mask, (50,50), (150,150), (0), thickness = -1)