DicomImage::writeBMP wrong with an US file

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
YueZijian
Posts: 6
Joined: Mon, 2012-11-05, 09:33

DicomImage::writeBMP wrong with an US file

#1 Post by YueZijian »

Image

Code: Select all

void test()
{
    DcmFileFormat dff;

    OFCondition c = dff.loadFile( "us.dcm" );

    if( c.bad() )
    {
        return;
    }

    DicomImage di( dff.getDataset(), EXS_Unknown );

    if( EIS_Normal != di.getStatus() )
    {
        return;
    }

    di.writeBMP( "test.bmp" );
}

Code: Select all

0028,0002,Samples Per Pixel=3
0028,0004,Photometric Interpretation=RGB
0028,0006,Planar Configuration=0
0028,0008,Number of Frames=1
0028,0010,Rows=576
0028,0011,Columns=768
0028,0030,Pixel Spacing=
0028,0100,Bits Allocated=8
0028,0101,Bits Stored=8
0028,0102,High Bit=7
0028,0103,Pixel Representation=1
0028,0120,Pixel Padding Value=0
0028,1050,Window Center=127.5 
0028,1051,Window Width=255 
0028,1052,Rescale Intercept=0 
0028,1053,Rescale Slope=1 
hi, can't find a way to upload the dcm file, any suggestion will appreciate, thanks a lot!

omarelgazzar
Posts: 101
Joined: Wed, 2009-07-08, 16:06
Location: Oldenburg, Germany

Re: DicomImage::writeBMP wrong with an US file

#2 Post by omarelgazzar »

Hello,
First, make sure that you include the following header file to support color images.

Code: Select all

#include "dcmtk/dcmimage/diregist.h"     /* include to support color images */
You can also try to check the output of the dcm2pnm tool to write BMP.

YueZijian
Posts: 6
Joined: Mon, 2012-11-05, 09:33

Re: DicomImage::writeBMP wrong with an US file

#3 Post by YueZijian »

Thank you, omarelgazzar!

Yes, I did include these headers:

Code: Select all

#include "dcmtk/dcmdata/dctk.h"
#include "dcmtk/dcmimage/diregist.h"
#include "dcmtk/dcmimgle/dcmimage.h"
And the dcm2pnm outputs the same result too, DCMTK-3.6.1_20121102.

Uli Schlachter
DCMTK Developer
Posts: 120
Joined: Thu, 2009-11-26, 08:15

Re: DicomImage::writeBMP wrong with an US file

#4 Post by Uli Schlachter »

YueZijian wrote:hi, can't find a way to upload the dcm file, any suggestion will appreciate, thanks a lot!
You can send the file per mail to dicom@offis.de (and don't forget to mention this forum thread).

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1437
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: DicomImage::writeBMP wrong with an US file

#5 Post by Marco Eichelberg »

The image is faulty in many ways (the most impressive error being that is uses CT Image Storage as SOP Class, despite being an Ultrasound image).
Your particular problem is caused by attribute (0028,0103) PixelRepresentation, which has a value of 1, meaning that the pixel data is signed, not unsigned.
ezDICOM probably ignores this attribute, but DCMTK correctly interprets it, thus creating an incorrect display. Try running

Code: Select all

dcmodify -m PixelRepresentation=0 us.dcm
and display the resulting modified file.

YueZijian
Posts: 6
Joined: Mon, 2012-11-05, 09:33

Re: DicomImage::writeBMP wrong with an US file

#6 Post by YueZijian »

Great help for me, it's worked, thanks! (You won't believe this, the standardization in my place, is horrible. :( )

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest