GDCM library cannot read dicom file in C# -


i tried read dicom file using gdcm library using code :

gdcm.imagereader imagereader = new gdcm.imagereader(); imagereader.setfilename(@"e:\sample_success.dcm"); if (!imagereader.read()) throw new exception("cannot read dicom file!"); 

for "sample_success.dcm" file, can read file fine (sample_success.png). using "sample_failed.dcm" file, gdcm throws exception because couldn't read it. tried open file using other dicom viewer such radiant , worked. there wrong gdcm build? why cannot read it?

i use gdcm 2.6.5. please find both samples here.

you're file contains garbage (bunch of binary 0) after offset 0x1480aa (somewhere in pixel data attribute). did expect toolkit if not report error ?

by design gdcm still load whatever can until error. if remove new exception in code, can decide (for example) pass imagereader.getfile() gdcm::writer , rewrite file clean dicom.

as side note not have access radiant software find odd not indicate error in case.

i've checked dcmtk , dicom3tools report parsing issue.

using gdcm command line tool can rewrite file clean using:

$ gdcmconv -i sample_failed.dcm sample_failed_correct.dcm 

because input dataset invalid, gdcm (falsely) believe see attribute, can remove using:

$ gdcmanon --dumb --remove 0,0 sample_failed_correct.dcm sample_failed_correct_clean.dcm 

and then:

$ gdcminfo sample_failed_correct.dcm  mediastorage 1.2.840.10008.5.1.4.1.1.3.1 [ultrasound multi-frame image storage] transfersyntax 1.2.840.10008.1.2.4.50 [jpeg baseline (process 1): default transfer syntax lossy jpeg 8 bit image compression] numberofdimensions: 3 dimensions: (800,600,21) samplesperpixel    :3 bitsallocated      :8 bitsstored         :8 highbit            :7 pixelrepresentation:0 scalartype found   :uint8 photometricinterpretation: ybr_full_422 planarconfiguration: 0 transfersyntax: 1.2.840.10008.1.2.4.50 origin: (0,0,0) spacing: (0.0106324,0.0106324,1) directioncosines: (1,0,0,0,1,0) rescale intercept/slope: (0,1) orientation label: axial 

which valid number of fragments in pixel data:

$ gdcmdump sample_failed_correct.dcm | grep item | grep "ff.d8" | wc      21     126    2856 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -