Reputation: 123
In OpenCV Library, filers are applied on all the image which costs time and CPU load when you need a specific result on a high resolution image.
Is there a method to apply it only on some specific points (contours for example)
Upvotes: 1
Views: 1813
Reputation: 20264
You can apply it on rectangular region like this:
img = cv2.imread('some_image.jpg')
roi_of_img = img[col:col+width,row:row+height]
then apply what you want on roi_of_img
if you want to apply it on contour, you have two options:
deal with it as rectangle (found the bounding rect of the contour as follow:
col, row, width, height = cv2.boundingRect(contours[i])
Deal with the rectangle bounding box and then apply bitwise and mask between the area inside the contour and the result of the ROI
Upvotes: 1