How to find contours only in black colour?

c++, image-processing, noise-reduction, ocr, opencv

Solution

Contour of black object will have an opposite orientation from a contour of white object (clockwise vs counter clockwise). You can check it by calling a function that calculates signed area:

if (contourArea(someContour,true) > 0)
    cout << "black" << endl;
else
    cout << "white" << endl;

Problem

I try to remove noises from an image. I have some black group of pixels in the image. I use cv::findContours and cv::boundingRect. And I fill small rectangles (small rectangles are noises in the image) with white colour. But this method also find me white contours (for example middle of black circle). How to find countours for black pixels? Is there any easy solution?

Original source