【发布时间】:2014-03-24 19:01:55
【问题描述】:
我得到一个 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();
以两种方式执行后,我只得到一个黑色图像。 任何机构都可以帮我解决这个问题吗?
【问题讨论】: