-2

I can displayed an image with Qt in a gui application.I want to obtain numeric(matrix) form of image, because I studied on image processing, but I cannot convert the displayed image to matrix form. I do not know what code is used. Can anyone help me with this? Code of displayed image is given below;

#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;
}

1 Answers1

0

I assume that you want to access pixel data in numeric form. You should use QImage instead of QPixmap. You can use size() to access image's size, pixel() to obtain QRgb value of a pixel, and qRed, qGreen, qBlue and qAlpha global functions to split QRgb value to color components. This should be enough to convert pixel data to matrix that can be stored in QVector< QVector<int> >.

Pavel Strakhov
  • 39,123
  • 5
  • 88
  • 127