【发布时间】:2019-03-16 13:27:56
【问题描述】:
我想知道是否有人可以帮助我解决这个问题。我有一个数组(单暗淡),它包含足够的 uint 值来填充大小为 120x160 的屏幕。我想将数组加载到垫子中并将其显示为灰度图像。我没看到有人能帮忙吗??提前致谢。
myarray[39360];
//..
//Code populates values between 0 and 255 to the array
// I have printed the array and the values are all 0 to 255
//..
Mat img,img1;
// load the array into a mat
img(120,160,CV_8UC1,myarray);
// convert the mat to a grayscale image, 3 channel instead of the current 1
img.convertTo(img1,CV_8UC3);
namedWindow("test",WINDOW_AUTOSIZE);
imshow("test",img1);
waitKey(0);
// windows pops up but just shows a gray blank page about mid tone :-(
【问题讨论】:
-
int是CV_32SC1所以尝试img(120,160,CV_32SC1,myarray);和img.convertTo(img1,CV_8U);这样之后,img1 将是一个 CV_8UC1 并且可以显示在 0 = 黑色和 255 = 白色的地方
标签: c++ arrays opencv grayscale