std::vector<std::vector<cv::Point> > contours; cv::vector<cv::Vec4i> hierarchy; cv::findContours(image, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_NONE, cv::Point(0, 0));
cv::Mat img, mor; cv::Mat element = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(5, 5)); cv::morphologyEx(img, mor, cv::MORPH_BLACKHAT, element, cv::Point(-1, -1), 3); cv::threshold(mor, mor, 0, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);