bitDepth and Maximum allowed data values

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
DanSV
Posts: 8
Joined: Fri, 2007-01-19, 16:33

bitDepth and Maximum allowed data values

#1 Post by DanSV » Tue, 2007-02-20, 20:40

Hello everyone. I developing a custom GUI with wxWidgets to 'flatten' dicom images obtained from endoscopic MRI imaging antennae. My program needs to read in and antenuate or amplified different pixel data based on a users mouse click.

Now the problem. My program needs to compute a ceiling for the data values in the MRI dicom file. Intuition told me that it would be 2^bitdepth-1. My images have a bitdepth of 14, so far, and it turns out that my real ceiling is 2^(bitdepth-2)-1, or 4095 for me. Am I changing the bitdepth by giving the DCMDataset a Uint16 * ? Also, doing a getMinMaxValues can return a max value of around 8000 instead of 4095, which is wierd also because I tested that a 4095 value maps to 255 in a BMP image with DCMTK. Any thoughts? Is there a way to set a new depth? Thanks,

Dan

CODE:::::::::::::::::::::::::::::

void overloadFrm::DCMClick(wxMouseEvent& event)
{

/*NOTE This Function can only be called from a wxMouseEvent off a wxStaticBitmap*/
// wxStaticBitmap * stB = (wxStaticBitmap *) event.GetEventObject();
wxBitmap dB(StaticDCM->GetBitmap());


DicomImage * holdDCM = DCM;
int w,h,x,y;
w = dB.GetWidth();
h = dB.GetHeight();
x = event.GetX();
y = event.GetY();
wxString msg;



msg.Printf( _T("Event Location: "));
msg << x << " "<< y << " out of " << w << " " << h;

if(HaveDicom())
{
msg << " depth " << holdDCM->getDepth();
double min,max;
holdDCM->getMinMaxValues(min,max);
msg << " min " <<min << " max " << max;
const Uint16 * DCMData;
DcmFileFormat * DCMFF = new DcmFileFormat();
DcmDataset * DCMDS;
OFCondition status = DCMFF->loadFile(DCMPath.GetFullPath().GetData());
DCMDS = DCMFF->getDataset();
OFCondition status2 = DCMDS->findAndGetUint16Array(DCM_PixelData,DCMData);
if(status.bad()) msg << " Didn't work "<< DCMPath.GetFullPath().GetData() ;//<< DCMData[1];
// if(status1.bad()) msg << " couldn't load data ";
if(status2.bad()) msg << " couldn't get array";
else msg << " point data " << DCMData[y*w+x] << " " << DCMBaseImage->GetBlue(x,y);
Uint16 * newdat = new Uint16[w*h];
long double PMax =( pow((long double)2,holdDCM->getDepth()-2)-1);
for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
{
if(PMax<(5*DCMData[i*w+j])) newdat[i*w+j]=PMax;
else newdat[i*w+j] = 5*DCMData[i*w+j];
}
msg << " PMax " <<(double) PMax;
status = DCMDS->putAndInsertUint16Array(DCM_PixelData,(const Uint16*)newdat,w*h);
if(status.bad()) msg << " Didn't put array ";//<< DCMData[1];

wxFileName FNH(DCMPath);
FNH.SetFullName("FileFormat.dcm");
DCMFF->saveFile(FNH.GetFullPath().GetData());

FNH.SetFullName("Dataset.dcm");
DCMDS->saveFile(FNH.GetFullPath().GetData());
}
wxMessageBox(msg, _T("Clicked and Got EventLocation"),wxOK | wxICON_INFORMATION, this);


event.Skip();

}

Post Reply

Who is online

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