[Dcmlib] Question about dicom imaging not being read correctly
Jean-Pierre ROUX
jean-pierre.roux at creatis.insa-lyon.fr
Sun Jan 20 11:54:18 CET 2008
At 5:16 +0000 20/01/08, Neerav Patel wrote:
>Hi,
>Using GDCM I have loaded up the raw byte array but the problem is when
>I show the image the really white areas seem to be corrupted and have
>turned black. Is there a setting that I havent set or something.
>Here is the code i have wrote:
> f = GDCM_NAME_SPACE::File::New();
Hi, Neerav!
The following lines are probabely useless in your case :
=====================
> f->SetLoadMode(GDCM_NAME_SPACE::LD_NOSEQ);
> f->SetLoadMode(GDCM_NAME_SPACE::LD_NOSHADOW);
> f->SetLoadMode(GDCM_NAME_SPACE::LD_NOSEQ |
>GDCM_NAME_SPACE::LD_NOSHADOW);
> f->SetLoadMode(GDCM_NAME_SPACE::LD_NOSHADOWSEQ);
====================
(and, anyway, you should just use *one* of them, not *all*, but the
problem doesn't start from here.
Note : using
f->SetLoadMode(GDCM_NAME_SPACE::LD_NOSEQ | GDCM_NAME_SPACE::LD_NOSHADOW);
may, sometimes, save some CPU time if you're just interested in
getting the pixels.)
What's the C++ type of imageData in :
imageData = fh->GetImageDataRaw();
GetImageDataRaw() returns an unsigned char*, and you have to cast it,
according what you know about your image (8/16 bits, signed/unsigned).
A misusage of signed/unsigned could lead to see 'brighter pixels' as dark.
Use File methods to be sure.
--> How do you display the image?
(if vtk installed on your computer, could you run :
vtkgdcmViewer2 yourDicomFileName
and see if the displayed image looks OK.
If it doesn't, could send me a sample of your image, so I can check
if somethind is going wrong with gdcm.
Thx
Jean-Pierre Roux
gdcm team
> f->SetFileName( filename );
> bool res = f->Load();
> if ( !res ) {
> f->Delete();
> MessageBox( NULL, "DICOM NOT LOADED", NULL, MB_OK );
> f = NULL;
> }
> if (!f->IsReadable()) {
> MessageBox( NULL, "Sorry, not a Readable DICOM / ACR
>File", NULL, MB_OK );
> f->Delete();
> f = NULL;
> return;
> }
> fh = GDCM_NAME_SPACE::FileHelper::New(f);
> fh->SetKeepOverlays(false);
> int nZ, sPP, planarConfig;
> std::string pixelType;
> imageWidth = f->GetXSize();
> imageHeight = f->GetYSize();
> nZ = f->GetZSize();
> pixelType = f->GetPixelType();
> sPP = f->GetSamplesPerPixel();
> planarConfig = f->GetPlanarConfiguration();
> int numberOfScalarComponents=f->GetNumberOfScalarComponents();
> dataSize = fh->GetImageDataRawSize();
> imageData = fh->GetImageDataRaw(); // somewhat important : Loads
>the Pixels in memory !
> if ( imageData == 0 ) {
> MessageBox( NULL, "Was unable to read pixels ", NULL, MB_OK );
> f = NULL;
> return;
> }
>
>Any help would be greatly appreciated.
>
>Thanks
>
>Neerav
>
>
><>
>
>_______________________________________________
>Dcmlib mailing list
>Dcmlib at creatis.insa-lyon.fr
>http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib
Jean-Pierre ROUX
CREATIS - CNRS UMR 5220, INSERM U 630
Laboratoire de Radiologie Experimentale
Hopital Cardiologique
28 Avenue du Doyen LEPINE
B.P. Lyon-Montchat
69394 Lyon Cedex 03
Tel : (+33) 04 72 35 74 12
Fax : (+33) 04 72 68 49 16
URL : http://www.creatis.univ-lyon1.fr/~jpr
e-mail : jpr at creatis.univ-lyon1.fr
More information about the Dcmlib
mailing list