Can smallest and largest pixel value be changed?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
yuhong
Posts: 10
Joined: Thu, 2005-04-21, 16:08
Location: Heidelberg, Germany

Can smallest and largest pixel value be changed?

#1 Post by yuhong »

Hi, everyone,

I have a question about the smallest and largest pixel value: if they can be changed manually or calculated automatically based on the pixel data?

I am trying to do some pixel processing work, first I read the original pixel data from a dicom file and then do pixel calculation, after that write back the pixel data. I also calculate the smallest and largest pixel value of the resulting pixel data and write back the new smallest and largest pixel value. But when I checked the resulting image again, I found the smallest and largest pixel value were not changed.

That means one does not need to change these two values manually?

Can anyone help me?

Thanks in advance.

Yuhong

here is the code:

Code: Select all

DcmFileFormat fileformat;
fileformat.loadFile( "original.dcm");
DcmDataset *ds = fileformat.getDataset();

ds->putAndInsertUint16( DCM_SmallestImagePixelValue, 100 );
ds->putAndInsertUint16( DCM_LargestImagePixelValue, 1000 );

fileformat.saveFile( "result.dcm" );
________
Herbal Vaporizer
________
Mazda Cx-9 Specifications
Last edited by yuhong on Sat, 2011-02-12, 16:03, edited 2 times in total.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

The helper method putAndInsertUint16() currently does not support the internal VR "xs" of these two attributes (which is US or SS). That means you have to create the DcmUnsignedShort element manually:

Code: Select all

DcmElement *us = new DcmUnsignedShort(DcmTag(DCM_SmallestImagePixelValue, EVR_US));
if (us != NULL)
{
   us->putUint16(100);
   ds->insert(us, OFTrue /*replaceOld*/);
}
We'll probably enhanced the helper methods for Uint16 and Sint16 in this regard for the next release.

Btw, you should always check the return value of the methods you're using.

yuhong
Posts: 10
Joined: Thu, 2005-04-21, 16:08
Location: Heidelberg, Germany

#3 Post by yuhong »

Hi, Riesmeier,

I tried and it worked.

Thank you very much!

Have a nice day!

Yuhong
________
Lexus Mc Specifications
________
DC MEDICAL MARIJUANA DISPENSARIES

Post Reply

Who is online

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