【发布时间】:2015-04-01 21:43:44
【问题描述】:
int sizeOfChannel = (_width / 2) * (_height / 2);
double* channel_gr = new double[sizeOfChannel];
// filling the data into channel_gr....
cv::Mat my( _width/2, _height/2, CV_32F,channel_gr);
cv::Mat src(_width/2, _height/2, CV_32F);
for (int i = 0; i < (_width/2) * (_height/2); ++i)
{
src.at<float>(i) = channel_gr[i];
}
cv::imshow("src",src);
cv::imshow("my",my);
cv::waitKey(0);
我想知道为什么我在我的和 src 的 imshow 中没有得到相同的图像
更新:
我已将数组更改为 double* 仍然相同的结果;
我认为这与步骤有关?
我的图像输出
src 图像输出
【问题讨论】:
-
可能是因为 channel_gr 是一个 int 数组,而不是一个 float 数组。
-
用CV_64F怎么样?或者使用 int 数组的问题可能是?
-
@ha9u63ar 抛出异常
-
这个 _width/2 是什么东西?还要注意,它是 Mat(row,cols,type),你把它反过来了。 (路上有很多坑坑洼洼,-恭喜,你都撞到了!)
-
@berak int sizeOfChannel = (_width / 2) * (_height / 2);获取原始图像并将其剪切成,因为我需要一个来自拜耳模式的通道。我对 cv::Mat(rows,cols,type); 没有问题我的问题是带有输入数组的ctor。像 Mat(int ndims, const int* sizes, int type, void* data, const size_t* steps=0);
标签: opencv