Displaying an image on Rgb channel
-
Hi everybody ^^ I've been working on a project lately,dealing with image compression.for a primar task,i have to develop an application that shows and image,then display it on the red,green and blue channels.for now I managed to display the image itself seccessfuly,but i couldn't extract it on any of the Rgb channels.here's a piece of my code where i'm working on the red channel:
@
QImage im;
im.load(//path of my image);
QVector <QRgb> table=im.colorTable();
for(int i=0;table.size();i++) {
table[i]=qRed(table[i]);
}
im.setColorTable(table);
QPixmap redvue;
redvue= QPixmap::fromImage(im);
QGraphicsScene *scene=new QGraphicsScene(m_ui->GraphicsScene);
m_ui->GraphicsScene->setScene(scene);
scene->addPixmap(redvue);
@[EDIT: code formatting, please wrap in @-tags, Volker]
-
The problem is that you have probably an image in true color without color palette.
To get the color, in such a case:
@
QImage im(//the path);QVector c[im.width()][im.height];
for (int i = 0; i<im.width(); i++)
for (int j=0; j<im.height(); j++)
c[i][j] = qRed(im.pixel());...
@