Remove small objects from binary image
Hello All,
I have an input binary image but with lot of unwanted particles which I want to remove small objects based on the area of the particles.
I have developed the code in MATLAB which works fine using bwareaopen function.
i came across connectedComponentsWithStats function which can help me solve my purpose, here is the section of my code:
Mat labels, stats, centroids;
connectedComponentsWithStats(inputbinaryimage, labels, stats, centroids, 8, CV_32S);
Later I verified the area of particles using stats output array which successfully detects those particles. Now I'm stuck at how to use the STAT_AREA function to filter out unwanted particles. One more thing is that the input image will be changing(position of the particles wont be same for the next image) so I can't use compare
function to filter out using labels.
Apart from connectedComponents are there any other functions which can perform the same operation much faster on the input binary image to get the desired output image.