OPENCV:使用地址操作员更改像素时的程序craches
我写了一个函数,可以在像素上进行一些计算。
Mat someCalc(Mat img) {
double min, max;
minMaxLoc(img, &min, &max);
double conRangeMin = 100;
double conRangeMax = 150;
Mat processed = img.clone();
for (int y = 0; y < processed.rows; y++) {
for (int x = 0; x < processed.cols; x++) {
double& pixel = processed.at<double>(y, x));
pixel = (pixel - conRangeMin) * ((max - min) / (conRangeMax - conRangeMin));
}
}
return processed;
}
我会收到以下错误:
该程序用错误代码崩溃“ -1073740940”,我注意到,如果我删除了Pixel
变量的adress运算符,则错误将消失。 直接更改像素时,也会发生同样的错误,例如processed。
当我
像素没有更改。我在做什么错?
I wrote a function, that does some calculations on a pixel.
Mat someCalc(Mat img) {
double min, max;
minMaxLoc(img, &min, &max);
double conRangeMin = 100;
double conRangeMax = 150;
Mat processed = img.clone();
for (int y = 0; y < processed.rows; y++) {
for (int x = 0; x < processed.cols; x++) {
double& pixel = processed.at<double>(y, x));
pixel = (pixel - conRangeMin) * ((max - min) / (conRangeMax - conRangeMin));
}
}
return processed;
}
I am getting the following error:
The program crashes with the error code "-1073740940" and I noticed that if I remove the adress operator for the pixel
variable, the error disappears. The same error happens when I change the pixel directly, like processed.at<double>(y, x) = ...
I am passing a grayscale image to the function.
The pixel isn't being changed. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论