opencv中的矩阵类型转换 [英] matrix type conversion in opencv
问题描述
我正在尝试使用过滤器对图像进行卷积,并借助opencv中的filter2D函数将其存储到CV_64F类型的矩阵中.但目标矩阵的类型已更改,我尝试借助assignTo 0r ConvertTo函数将其更改回CV_64F,但我无法这样做.有人可以帮忙吗?这是我的代码行
I am trying to convolve an image with a filter and storing it to a matrix of type CV_64F with the help of filter2D function in opencv. but the type of the destination matrix get changed and i try to change it back to CV_64F with the help of assignTo 0r ConvertTo function but i am not able to do so. Can someone help? This is lines of my code
cv::Mat op = cv::Mat(25,25,a.type(),Arr1); // a is the image matrix and op is the filter.
cv::Point anchor = Point(-1,-1);
cv::Mat b = cv::Mat(a.size(),CV_64F);
cv::Mat l = cv::Mat(a.size(),CV_64F);
cv::Mat m = cv::Mat(a.size(),CV_64F);
//prnmt(a);
filter2D(a,b,-1,op,anchor,0,BORDER_DEFAULT);
b.assignTo(l,CV_64F);
推荐答案
我尝试使用OpenCV 2.3运行以下类似代码,并且可以正常工作,即在调用filter2D
后b
的类型为CV_64F
:
I tried running the following similar code with OpenCV 2.3 and it worked i.e. b
's type was CV_64F
after the call to filter2D
:
cv::Mat a(100, 100, CV_64F);
cv::Mat op(25, 25, CV_64F);
cv::Mat b(a.size(), CV_64F);
cv::Mat l(a.size(), CV_64F);
cv::Mat m(a.size(), CV_64F);
cv::Point anchor(-1, -1);
filter2D(a, b, -1, op, anchor, 0, cv::BORDER_DEFAULT);
您确定代码中的a
是CV_64F
吗?
filter2D
转换为b
的类型是什么?
To what type is b
getting converted to by filter2D
?
您正在使用哪个版本的OpenCV?
Which version of OpenCV are you using?
这篇关于opencv中的矩阵类型转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!