Displaying Ultrasound RGB image from getInterdata()

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

Displaying Ultrasound RGB image from getInterdata()

#1 Post by martinrame »

Hi, I need to display an Ultrasound RGB image in a Delphi program without using getOutputData (I use it and it works ok on other programs). So, the "low level" alternative is using getInterdata, right?.

Ok, here's how I'm getting the data buffer (in a c++ shared library):

Code: Select all

        const DiPixel * interdata = imgHandler->getDicomImage()->getInterData();
        EP_Representation rep = interdata->getRepresentation();
        switch(rep)
        {
            ...
           case EPR_Uint8:
            {
                bufSize = interdata->getCount();
                buffer = new Uint8[bufSize];
                break;
            }
            ...
        }
        // buffer is a reference to a void * variable
        memcpy((void *)buffer, interdata->getData(), bufSize);
The returned buffer is an Uint8 array, in Pascal is PByte, so, to display the image I declared lBuf as PByte;

Code: Select all

    lTmpBuf := lBuf;
    for llY := 0 to ImgHeight - 1 do
    begin
      lScanLine := FCanvasImage.ScanLine[llY];
      for llX := 0 to ImgWidth - 1 do
      begin
        lRed := lTmpBuf[0];
        lGreen := lTmpBuf[1];
        lBlue := lTmpBuf[2];
        lScanLine^ := lRed or (lGreen shl 8) or (lBlue shl 16) or (alphaOpaque shl 24);
        inc(lTmpBuf);
        inc(lScanLine);
      end;
    end;
Original Image:
Image

My Result:
Image

As you can see there are two differences:

1) Colors are wrongly displayed.
2) The image displayed by my program is displaced (the +/-100 pixels of the right must be shown at the left side).

Can you help me figure out why my program is displaying it wrong?.

Thanks in advance.

J. Riesmeier
DCMTK Developer
Posts: 2505
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Displaying Ultrasound RGB image from getInterdata()

#2 Post by J. Riesmeier »

First question: Why are you using getInterData() for color images? This is not the way it should be done!

You have to understand that getInterData() provides a low-level access to the internally stored pixel data.
For color images, DiPixel::getData() returns an array of pointers to the 3 planes: http://support.dcmtk.org/docs/classDiCo ... 4aa4e7fe29

martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

Re: Displaying Ultrasound RGB image from getInterdata()

#3 Post by martinrame »

Sorry Jörg, as you can see, I'm using getDicomImage()->getInterData()->getData() to access pixels.

Is there another way to call getData() without first getting a reference to getInterData() ?.

J. Riesmeier
DCMTK Developer
Posts: 2505
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Displaying Ultrasound RGB image from getInterdata()

#4 Post by J. Riesmeier »

Please reread my last posting!

martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

Re: Displaying Ultrasound RGB image from getInterdata()

#5 Post by martinrame »

J. Riesmeier wrote:Please reread my last posting!
Do you mean I should use getOutputData() for color images?.

J. Riesmeier
DCMTK Developer
Posts: 2505
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Displaying Ultrasound RGB image from getInterdata()

#6 Post by J. Riesmeier »

This is certainly the preferred option. If you still want to use getInterData(), then you should understand how the pixel data is stored internally (i.e. within the dcmimgle/dcmimage classes).

martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

Re: Displaying Ultrasound RGB image from getInterdata()

#7 Post by martinrame »

J. Riesmeier wrote:This is certainly the preferred option. If you still want to use getInterData(), then you should understand how the pixel data is stored internally (i.e. within the dcmimgle/dcmimage classes).
Ok, I've choosed the getOutputData path, but thinking a a little more about getInterdata()->getData() with RGB images, I think the pixels are stored as an array [0..2] of arrays of pointers:

[0][0..n]
[1][0..n]
[2][0..n]

Am I right?.

J. Riesmeier
DCMTK Developer
Posts: 2505
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Displaying Ultrasound RGB image from getInterdata()

#8 Post by J. Riesmeier »

Yes, and this is what I wrote in my above posting ("For color images, DiPixel::getData() returns an array of pointers to the 3 planes...") and what is documented in the referenced API documentation (also see above posting) :)

martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

Re: Displaying Ultrasound RGB image from getInterdata()

#9 Post by martinrame »

J. Riesmeier wrote:Yes, and this is what I wrote in my above posting ("For color images, DiPixel::getData() returns an array of pointers to the 3 planes...") and what is documented in the referenced API documentation (also see above posting) :)
Mmm, we must agree the documentation is not clear enough, why not adding this:

"The returned array [0..2] points to the three image planes. Where each plane is a pointer array composed of Rows * Cols * getInterData()->getCount()."

J. Riesmeier
DCMTK Developer
Posts: 2505
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Displaying Ultrasound RGB image from getInterdata()

#10 Post by J. Riesmeier »

Originally, there was NO access to the internally stored pixel data. This is why it is called INTERNAL.

However, due to public demand I opened the door, but mainly for grayscale images (Hounsfield Units for CT images). I'm still not happy with this access to the internal data structures and, especially in your case (color images), I cannot understand why you prefer this way.

Btw, what do you mean by "Rows * Cols * getInterData()->getCount()"? Also a plane is no pointer array!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest