Re: [Gdcm2] Buffer problem in Qt environment
Cross-platform DICOM implementation
Brought to you by:
malat
|
From: Sylvain A. <syl...@ho...> - 2009-06-16 08:45:31
|
Salut Mathieu.
Thanks for the answers !!
Yeah I finally got almost what I wanted by displaying my image in a QImage. But as I said earlier, well, I'm still using the RGB16 format of the QImage class.
The RGB888 format doesn't work. I actually looked over the API (maybe not deep enough), both from GDCM and Qt, and I still don't have any clue on how to display my image correctly in Qt and how to access 16bits pixel information at coordinate (x, y) on the original image!
For now, I can just get the grayscale value on my QImage (which is actually blue-green because of the format used) by calculating it using the RGB value. So I get a gray value from 0 to 140, which is not the usual gray value for a DICOM image in here. We usually have something from 0 to 2000 ~ich.
I tried the getPhotometricInterpretation() function, to see what does this return: MONOCHROME2. And that's it. The getSamplesPerPixel returns 1. I'm afraid my image knowledge is a bit limited!
As the QImage is my display image, getting information from it is not what I intend to do ('cause for display reasons, we don't really need 16-bits, do we?).
Another thing for now, does anyone have had this error before? This happens when I'm using the buffer. This is just displayed by my application output in debugging mode:
HEAP[IntensityProfileGUI.exe]:
Invalid Address specified to RtlFreeHeap( 05080000, 04DAA558 )
The message is displayed twice in my debugger. Well, even if I'm using two or one buffer, and when I comment the buffer line, it does not appear anymore.
Thanks for helping me.
Sylvain.
> Date: Fri, 5 Jun 2009 16:55:22 +0200
> Subject: Re: [Gdcm2] Buffer problem in Qt environment
> From: mat...@gm...
> To: syl...@ho...
> CC: gdc...@li...
>
> Sylvain,
>
> On Tue, Jun 2, 2009 at 4:54 PM, Sylvain ADAM<syl...@ho...> wrote:
> > Okay... My mistake... I haven't quite looked at what I've done.
> >
> > Actually the code is working when I'm instanciating a char* like this:
> >
> > char *buffer = new char[gimage.GetBufferLength()];
> >
> > I'm still trying to find the right format for my QImage, though, 'cause I've
> > token an RGB16 format, I can see my dicom image but it's weird.
>
> Everything is fine since you are passing the *whole* buffer. You can
> see the 'char*' as if it was simply a generic void* pointer in C.
> GetBufferLength (see documentation) will return the size of
> dimX*dimY*sizeof(pixel=)*numberofpixel
>
> So simply do:
>
> QImage *imageQt = new QImage(buffer2, dimX, dimY, QImage::Format_RGB888);
>
> You should be extremely careful on how you write this code, as it is
> the most error-prone part. You absolutely need to check the value from
> image.GetPixelFormat().GetNumberOfSamples and
> image.GetPhotometricInterpretation to avoid doing any kind of mistake.
>
>
> > By the way, does everyone know if there's a way to access the dicom pixel
> > information for a known location (i, j) ?
>
> Yes, build a QImage and use the API :)
>
>
> HTH
> --
> Mathieu
_________________________________________________________________
Téléphonez gratuitement à tous vos proches avec Windows Live Messenger ! Téléchargez-le maintenant !
http://www.windowslive.fr/messenger/1.asp |