Hi there,
I had no problem in the past writing the DICOM file using unsigned Uint16 type.
Now I try to write a DICOM file with Sint16 datatype (and Rescale\Intercept).
I tried 2 different ways and both give me various trouble in my scenario:
What am I doing wrong? Is there a better way? Thank you.
a)
Sint16* pixdata;
DcmFileFormat* FF;
.....
DcmDataSet* dDS = FF->getDataSet();
BytesPerPixel = 2;
dDS->putAndInsertUint8Array(DCM_PixelData,(Uint8*)(pixdata),NumPix*BytesPerPixel );
dDS->putAndInsertUint16( DCM_PixelRepresentation,EPR_Sint16 );
....
FF->saveFile( Name,...
b)
Sint16* pixdata;
DcmFileFormat* FF;
.....
DcmDataSet* dDS = FF->getDataSet();
dDS->putAndInsertSint16Array(DCM_PixelData,(Sint16*)(pixdata),NumPix );
..............
FF->saveFile( Name,...
How to write DICOM file with Sint16 pixel representation
Moderator: Moderator Team
-
- Posts: 32
- Joined: Mon, 2018-11-12, 20:01
-
- DCMTK Developer
- Posts: 2051
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Re: How to write DICOM file with Sint16 pixel representation
Hi,
Integer Pixel Data always has data type OB or OW and the only methods that work on that are putAndInsertUint8() or. ..16 respectively.
So you have to prepare your Sint16 array and insert it using putAndInsertUint16() by casting it to Uint16. In the end its just raw data and the reader must interpret it by looking at tags like Bits Allocated/Stored, High Bit (...) and Pixel Representation where the latter tells whether to interpret values signed (Pixel Representation=1) or unsigned (=0).
Best regards,
Michael
Integer Pixel Data always has data type OB or OW and the only methods that work on that are putAndInsertUint8() or. ..16 respectively.
So you have to prepare your Sint16 array and insert it using putAndInsertUint16() by casting it to Uint16. In the end its just raw data and the reader must interpret it by looking at tags like Bits Allocated/Stored, High Bit (...) and Pixel Representation where the latter tells whether to interpret values signed (Pixel Representation=1) or unsigned (=0).
Best regards,
Michael
-
- Posts: 32
- Joined: Mon, 2018-11-12, 20:01
Re: How to write DICOM file with Sint16 pixel representation
Thank you so much - you advice worked.
Confusion came from using the "representation" from the DicomImage object
DicomImage* Img;
...
const DiPixel *obp = Img->getInterData();
EP_Representation PixRep = obp->getRepresentation();
Now it is clear that the DCM_PixelRepresentation {0,1} is entirely different from the EP_Representation.
Confusion came from using the "representation" from the DicomImage object
DicomImage* Img;
...
const DiPixel *obp = Img->getInterData();
EP_Representation PixRep = obp->getRepresentation();
Now it is clear that the DCM_PixelRepresentation {0,1} is entirely different from the EP_Representation.
-
- DCMTK Developer
- Posts: 2051
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Re: How to write DICOM file with Sint16 pixel representation
Great, happy that it worked. I could have stated the difference to EP_Representation more clearly.
Best regards,
Michael
Best regards,
Michael
Who is online
Users browsing this forum: Google [Bot] and 1 guest