PDA

View Full Version : Speeding up Image Rendering



reno77
15th June 2010, 09:50
I'm currently working on a medical imaging software and need to overlay the atlas of the brain corresponding to the MRI image slice . I'm using graphicsview & graphicscene to display the images, the code i'm using to display the atlas images is below.

pAtlasImage is the current atlas 24 bit BMP image array

QImage image(nAtlasWidth,nAtlasHeight,QImage::Format_RGB8 88);
memcpy(image.bits(), pAtlasImage, nAtlasWidth*nAtlasHeight*3);
image = image.rgbSwapped();//Returns a QImage in which the values of the red and blue components of all pixels have been swapped, effectively converting an RGB image to an BGR image.
atlas_qpixmap_image = QPixmap::fromImage(image,Qt::AutoColor);
atlas_qpixmap_image.setAlphaChannel(atlas_qpixmap_ image.createMaskFromColor(Qt::white, Qt::MaskOutColor));
atlas_1_qgpixmap = scene[m_nSliceCurrent]->addPixmap(atlas_qpixmap_image.scaled(w,h,Qt::Ignor eAspectRatio, Qt::FastTransformation));

The code is laggy and jumps some frames when I'm scrolling through the MRI images, due mainly to the setAlphaChannel call, is there anyway to speed the code by using a QPainter somewhere instead of a QPixmap or QImage ?

aamer4yu
15th June 2010, 09:54
What if you use opengl in graphics view ?
QGraphicsView::setViewport(new QGLWidget)

wysota
15th June 2010, 09:58
You can speed things up if you use a format other than bmp - then you won't have to swap the channels which is quite a time intensive process. The same as creating a mask by scanning colors of the image, can you have that precalculated?. Also you can scale the image before doing those transformations, this will significantly reduce the amount of data that needs to be processed.