c++ - 将 Mat 图像转换为 QImage 后图像质量失真
问题描述
void Qtexample::on_pushButton_clicked()
{
QString img_path = QFileDialog::getOpenFileName(this, "Select your image", QDir::homePath());
img = imread(img_path.toStdString().c_str());
Size size(200, 200);
cv::resize(img, img,size);
cvtColor(img, img, COLOR_RGB2BGR); //convering the image to RGB for QImage to handle well
QImage Qimg((uchar*)img.data, img.cols, img.rows, img.step, QImage::Format_RGB888); // converting Mat image to QImage
ui.label->setPixmap(QPixmap::fromImage(Qimg,Qt::AutoColor).scaled(ui.label->width(), ui.label->height())); // displaying the image inside the QLabel with the help of QPixmap
// imshow("image", img); // show image
}
该代码通过将 Mat 图像转换为 QImage 来工作,但生成的图像有点失真,我需要帮助。
解决方案
推荐阅读
- azure - Azure 文件存储:ClientOtherError 计数高
- python - 从 lxml 导入 html(×)
- python - 如何在循环期间绘制子图
- typescript - ESLint 在模板中找不到未定义的方法或属性
- tesseract - 正方体 OCR 音高文本
- mysql - 我试图将我的 SpringBoot 应用程序与本地主机中的 MySQL 数据库连接起来。但它显示了这个错误。(我的 MySQL 版本是 5.0)
- java - 在将 Maven 多模块项目从 git 克隆到 intellij 时,不会自动设置源、测试源和资源根
- mysql - Mysql SUM 和 GROUP BY 来自 3 个表
- docker - 了解 docker 端口分流
- sql - LIKE 运算符作为 RegEx 的替代品