使用 Image.ptr<double>(0);在 OpenCV 中使用彩色图像
Using Image.ptr<double>(0); with color image in OpenCV
我正在OpenCV(c++)中学习GrabCut,我坚持使用这一行
coefs = model.ptr<double>(0);
mean = coefs + componentsCount;
cov = mean + 3*componentsCount;
其中
模型是矩阵
coeffes、mean和cov是双*
componentsCount是一个常量整数
我想知道系数是多少?是RGB值还是其他什么?(以下代码的结果)
model.ptr<double>(0);
行中发生了什么
cov = mean + 3*componentsCount;
谢谢你的回答!!:)
Mat model
不是彩色图像,而是高斯混合模型的模型。
GMM有以下私人成员:
Mat model;
double* coefs;
double* mean;
double* cov;
model
—单通道双矩阵(CV64FC1
),1行,列数等于modelSize*componentsCount
,其中
componentsCount = 5 // line 60
modelSize = 13 // 3/*mean*/ + 9/*covariance*/ + 1/*component weight*/ // line 89
该数据存储在具有以下布局的矩阵model
中:
cw0, cw1, cw4, m00, m01, m02, m10, ..., m42, c00, c11, ...
^ ^ ^
coefs = model.ptr<double>(0) ^
mean + 3*componentsCount
^
^
coefs + componentsCount
其中:
cw<i> is the weight of the i-th component
m<i><j> is the j-th dimension mean of the i-th component
c<i><j> is the j-th dimension covariance of the i-th component
因此:
coefs = model.ptr<double>(0); // points at the start of the weights into model
mean = coefs + componentsCount; // points at the start of the means into model
cov = mean + 3*componentsCount; // points at the start of the covariances into model
ptr<double>()
只是在第0行的开头返回一个double*
,即数据进入矩阵的开头。它相当于(double*)model.data
。
基本上,coefs
、mean
和cov
只是将适当的数据放入model
的快捷方式。
相关文章:
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 彩色图像的卤化物处理平均值
- 如何在 OpenCV 中将图像与另一个图像相关联
- OpenCV C++将灰色图像组合成彩色图像
- 使用opencv的C++图像检测
- 在 matlab 中调用 opencv 的图像时,无法读取 C++ 中的图像
- 使用 OpenCV 和 C++将 16 位灰度图像更改为彩色图像
- 使用 OpenCV 更改图像的颜色
- 如何使用 openCV 更改图像每个像素的颜色
- 彩色图像的边缘检测 CannyAlgorithm.
- 是否有彩色图像的Surf_cuda实现
- 如何使用OpenCV从图像中检测旋转对象
- OpenCV将我自己的过滤器应用于彩色图像
- 在 OpenCV 中将图像转换为彩色铅笔素描
- Opencv如何使用MatIterator迭代具有浮动RGB值的彩色图像
- 使用 Image.ptr<double>(0);在 OpenCV 中使用彩色图像
- opencv Qt如何有效地创建彩色图像并将其传递给QImage
- OpenCV将彩色图像转换为灰度
- 在OpenCV 2中混合彩色图像和灰度图像
- Opencv:: 将Mat_< Vec3f>转换为普通的 8 位彩色图像