【问题标题】:How to convert image to matrix form in QtCreator?如何在 QtCreator 中将图像转换为矩阵形式?
【发布时间】:2013-12-18 17:34:04
【问题描述】:

我可以在 gui 应用程序中使用 Qt 显示图像。我想获得数字(矩阵)形式的图像,因为我研究过图像处理,但我无法将显示的图像转换为矩阵形式。我不知道使用什么代码。谁能帮我这个? 显示图像代码如下;

#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow
{
ui->setupUi(this);
QPixmap pix("/home/zeynep/Masaüstü/right.jpg");
QRegion exposed;
pix.scroll(-90,100,pix.rect(), &exposed);
ui->label_pic->setPixmap(pix);
}
MainWindow::~MainWindow()
{
delete ui;
}

【问题讨论】:

  • 你能改写一下这个问题吗?
  • 请提供更多详细信息,说明您采取的步骤、结果如何以及您的预期。

标签: c++ qt qt-creator qtgui


【解决方案1】:

我假设您想以数字形式访问像素数据。您应该使用QImage 而不是QPixmap。您可以使用size() 获取图像的大小,pixel() 获取像素的QRgb 值,qRedqGreenqBlueqAlpha 全局函数将QRgb 值拆分为颜色组件。这应该足以将像素数据转换为可以存储在QVector< QVector<int> > 中的矩阵。

【讨论】:

    猜你喜欢
    • 2022-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-06
    • 2014-05-09
    相关资源
    最近更新 更多