[英]I cant iterate through pixels of all the image, it is iterating through parts of it. OpenCV
I have the following code:我有以下代码:
void white(Mat&src,Mat&dst){
double h = src.cols;
double w = src.rows;
dst = src.clone();
for (int i = 0; i < dst.rows; i++) {
for (int j = 0; j < dst.cols; j++) {
dst.at<uchar>(i, j) = 255;
}
}
}
My expected result is to get a completely white image, however, I get this result:我的预期结果是得到一个完全白色的图像,但是,我得到了这个结果:
Input Image:输入图像:
Output Image: Output 图片:
It's a color image.是彩色图像。 Each pixel consists of 3 values.每个像素由 3 个值组成。 You have to set each color channel您必须设置每个颜色通道
void white(Mat&src,Mat&dst){
double h = src.cols;
double w = src.rows;
dst = src.clone();
for (int i = 0; i < dst.rows; i++) {
for (int j = 0; j < dst.cols; j++) {
for (std::size_t c = 0; c < 3; ++c) {
dst.at<Vec3b>(i, j)[c] = 255;
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.