opencv:遍历访问像素

    for (int row = 0; row < height; row++) {
        for (int col = 0; col < width; col++) {
            if (dim == 3) {
                Vec3b pixel = src.at<Vec3b>(row, col);
                int blue = pixel[0];
                int green = pixel[1];
                int red = pixel[2];
                src.at<Vec3b>(row, col)[0] = 255 - blue;
                src.at<Vec3b>(row, col)[1] = 255 - green;
                src.at<Vec3b>(row, col)[2] = 255 - red;
            }
            if (dim == 1) {
                int pv = src.at<uchar>(row, col);
                src.at<uchar>(row, col) = (255 - pv);
            }
        }
    }
上一篇:Python:将曲线拟合到整数列表


下一篇:c和opencv获取并设置像素颜色为Mat