PDA

View Full Version : Bitplane separation an 8bit depth gray scale image, how?



szakos
22nd April 2011, 13:49
Hello,
I would like to load an 8-bit grayscale image and extract its eight bitplanes. Is it possible with QImage? Should I use the QBitArray and than QBitmap or my approach is wrong?

szakos
23rd April 2011, 00:36
So, I loaded the grayscale image pixels as QImage to an array



QVector<QRgb> szinindextabla = image.colorTable();
QVector<QVector<quint8> > a(image.width(), QVector<quint8>(image.height()));
for(int i=0;i<image.height();i++){
for(int j=0;j<image.width();j++){

a[j][i]=qGray(szinindextabla[image.pixelIndex(j,i)]);

}
}


Now, how to extract the bits?

Added after 14 minutes:

hm, i don't think this is the right approach, but it almost works, i created a QBitarray and do & 2^{bitplane no} then created QBitmap then draw points with QPainter on the QBitMap when bit is true. The LSB bitplane looks quite random and this is normal, but the 8th is complete white and it is not good.