opencv对像素进行操作

Mat pic = imread(str, CV_LOAD_IMAGE_COLOR);
    int channels=pic.channels();
    int rows = pic.rows;
    int cols = pic.cols;
    for (int i = 0; i < rows; i++)//像素的遍历
    {

        for (int j=0; j < cols; j++)
        {
            pic.at<Vec3b>(i, j)[2]=0;//b通道
            pic.at<Vec3b>(i, j)[0] = 0;//g通道
            pic.at<Vec3b>(i, j)[1] = 0;//r通道
        }
    }

猜你喜欢

转载自blog.csdn.net/qq_36786800/article/details/88987407