OPENCV:使用地址操作员更改像素时的程序craches

发布于 2025-02-10 12:40:06 字数 676 浏览 1 评论 0原文

我写了一个函数,可以在像素上进行一些计算。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文