I have some processed images that have noise (background pixels) around the boundaries. Is there a way to detect only the boundary of the object itself and create a mask to remove the background pixels around the boundaries?
Im a beginner to OpenCV so any code samples would help.
Example:
Original Image
Processed Image
Expected Output
I have tried the findContours
method but it creates a mask that includes the noisy pixels as well.
Also i have tried the erode
method but it does not give the same results for different image sizes so that is not the solution im looking for.