- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 cv2::absdiff()
从图像矩阵中减去标量。我使用的代码是:
double min;
double max;
Scalar mean;
Scalar std_dev;
minMaxLoc(img_a_color_planes[1], &min, &max);
meanStdDev(img_a_color_planes[1], mean, std_dev);
Mat img_a_color_planes[3];
split(img_a, img_a_color_planes);
Mat oper = img_a_color_planes[1];
absdiff(oper, mean, oper);
divide(oper, std_dev, oper);
multiply(oper, 10, oper);
add(oper, mean, oper);
在这里,我特意将 img_a
的绿色 channel 复制到 Mat oper
中,尽管在 中指定了输出矩阵
。即便如此,绿色 channel oper
>绝对差异img_a_color_planes[1]
也会受到影响。我不明白这是为什么。我怎样才能避免这种情况?以下是我的 img_a
在 absdiff
操作后受到影响的方式:
初始img_a
:
最佳答案
问题是 Mat oper = img_a_color_planes[1];
不复制底层数组,只复制 header 数据。这同样适用于 copy constructor .
您需要制作一个独立的拷贝,以避免对原始图像进行更改。一种方法是通过 clone()
方法:Mat oper = img_a_color_planes[1].clone();
。克隆在后台使用 copyTo()
:https://stackoverflow.com/a/15688165/2988730 .
引用 Mat
docs :
Use a copy constructor or assignment operator where there can be an array or expression on the right side (see below). As noted in the introduction, the array assignment is an O(1) operation because it only copies the header and increases the reference counter. The
Mat::clone()
method can be used to get a full (deep) copy of the array when you need it.
关于c++ - 无法理解 cv2::absdiff 的行为:c++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41397945/
我正在尝试使用蒙版计算两个图像的绝对差异,因此在计算差异时只考虑图像的一个区域。但是 OpenCV 在 its function 中没有掩码部分.我看到了this question但对我不起作用。我试
我试图找到两张图片之间的区别,但是,我正在使用 JavaCV,虽然我发现了一个 openCV 函数,它似乎可以满足我的需要,但我似乎无法让它工作,因为我不确定我如何在 java 中使用 cvAbsDi
OpenCV 的 cv::absdiff(InputArray src1, InputArray src2, OutputArray dst) 使用什么方法/算法? 对于 1 channel Mat,
我正在使用 cv2::absdiff() 从图像矩阵中减去标量。我使用的代码是: double min; double max; Scalar mean; Scalar std_dev
我正在尝试使用 OpenCv 从图像中检测条形码,我正在使用渐变法:http://www.pyimagesearch.com/2014/11/24/detecting-barcodes-images-
我一直在研究一个通过背景减去来检测手的程序。我试图将相机的第一帧保存为背景并减去当前帧,但它们似乎以某种方式具有不同的亮度。我已经试了好几次了,但我没有换灯,可能是什么问题? image1 image
使用 Peano 风格的类型级自然函数,编写绝对差异类型级函数(又名类型族)相当容易: {-# LANGUAGE DataKinds, StandaloneKindSignatures, TypeFa
如何使用 magnitude和 absdiff ?我阅读了the documentation中的解释,但每次它都会出错,因为我不明白输入数组和输出究竟应该如何。应该是vector , Mat或 Sca
有谁知道如何让 absdiff 在 opencv 中工作。以下代码给出错误: @Override public void onManagerConnected(int status) {
这是来自 C++ 的示例: cv::absdiff(input,cv::Scalar(target),output); 其中 target 是 cv::Vec3b [190, 119, 102] 我在
是否可以在没有临时 img 的情况下计算 cv2.absdiff(img1, img2).sum() ? 我有一个视频流,我需要在处理开始时进行某种图像稳定。absdiff 在使用以下两个图像检查不同
我是一名优秀的程序员,十分优秀!