opencv求像素总数并进行筛选


 
    vector hierarchy;
    vector> contours;
    findContours(src, contours, hierarchy, RETR_LIST, CHAIN_APPROX_NONE);
    int i;
    for (i = 0; i < contours.size(); i++) {
        Mat c =(Mat) contours[i];
        Scalar color(0, 0, 0);
        int a = fabs(contourArea(c));
        if (a < 2000) {
            drawContours(src, contours, i, color, CV_FILLED);
        }
    }

你可能感兴趣的:(opencv)