Hello, I am a beginner in OpenCV and I am trying to segment an image. I got it by getting the largest contour in the canny image and then I used the x, y, w, h of the boundingRect() to the original image then I turn the ROI into grayscale but the problem is other images resulted having these unwanted parts (the ones in green lines) touch the ROI.
Example:
How can I remove those kind of noises?
Here is the image: