How I can remove this noise (rectangle 2x2px) from binary image?
How to remove specific noise from image with OpenCV
601 Views Asked by Ilia Fedorov At
3
There are 3 best solutions below
0
On
Both @melodisease and @Jazz suggested reasonable solutions. If you plan to go for connected components and to select those larger than a specific area, don't use findContours(). Use a recent OpenCV and go for cv::connectedComponentsWithStats(). You'll find it much faster.
Full disclosure: I contributed the algorithm...

Median filtering (
cv::medianBlur()) / morphology operations (cv::morphologyEx(), you needopening, I believe) are often used for your case - they enable cleaning out the isolated pixels. See more in here.