在Qt中显示浮点图像
To display float point image in Qt
我在0到1的范围内得到一个浮点图像。我试图使用标签在Qt中显示这个浮动图像,但它不起作用。我检查了QImage格式,发现Qt不支持浮动图像。现在我正试着用这种方法……
QVector<QRgb> colorTable;
for (int i = 0; i < 256; i++)
colorTable.push_back(qRgb(i, i, i));
Mat img2;
DepthImg.convertTo(img2, CV_8UC1);
assert(img2.isContinuous());
QImage image = QImage((unsigned char*)(img2.data), DepthImg.cols, DepthImg.rows, QImage::Format_Indexed8);
image.setColorTable(colorTable);
ui.ThreeD->setPixmap(QPixmap::fromImage(image, Qt::AutoColor));
ui.ThreeD->setScaledContents(true);
qApp->processEvents();
this->ui.ThreeD->show();
这里的"DepthImage"是一个浮点图像。
Mat img2;
DepthImg.convertTo(img2, CV_8UC1);
assert(img2.isContinuous());
QImage image = QImage((unsigned char*)img2.data, img2.cols, img2.rows, img2.cols*3, QImage::Format_RGB888);
ui.ThreeD->setPixmap(QPixmap::fromImage(image, Qt::AutoColor));
ui.ThreeD->setScaledContents(true);
qApp->processEvents();
this->ui.ThreeD->show();
以两种方式执行后,我只得到一个黑色的图像。谁能帮我解决这个问题?
您需要按255倍缩放图像。你可以通过修改
DepthImg.convertTo(img2, CV_8UC1);
DepthImg.convertTo(img2, CV_8UC1, 255.0);
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- C++射线示踪剂ppm表示没有足够的数据来显示图像
- 如果不在窗口 10 中声明名为 openCV 的 openCV namedWindow,QT 图像显示将无法正常工作
- 我在 OpenGL 中显示图像时遇到问题
- C++ 窗口显示无框图像
- 裁剪并显示我从哈尔级联获得的图像
- 如何显示具有 opengl 纹理的灰度图像
- 使用 Splashkit 逐个显示多个C++图像
- 如何使用OpenCV同时显示"深度"和"颜色"视频图像
- 如何从amd gpus的显示输出中获取图像数据
- Qt-png图像未显示在部署应用程序中
- 无法在 Opencv 中显示图像导致内存位置
- 只有左侧图像显示在OpenGL Stereo上
- gstreamer 管道代码,用于通过来自相机的实时流式传输而不是图像显示文本
- wxnotebook动态图像显示
- OpenCV-关闭图像显示窗口
- Qt拖放-改变图像显示,而拖动
- 为什么从Project Tango Tablet中提取的图像显示为灰色
- 如果同时运行两次wkhtmltopdf库,为什么它只会发生数据文档,而没有任何表或图像显示在html文件中
- 如何在win32中刷新图像显示白色,保持文字不变