Login  Register

Re: Problem while adding dicom header to a jpeg and save the image as DICOM

Posted by Johannes Hermen on Aug 27, 2009; 6:20am
URL: http://imagej.273.s1.nabble.com/Problem-while-adding-dicom-header-to-a-jpeg-and-save-the-image-as-DICOM-tp3691389p3691390.html

> Problem while adding dicom header to a jpeg and save the image as DICOM
>
> Hi am getting an exception
> java.lang.ClassCastException: org.dcm4cheri.util.UIDGeneratorImpl cannot
be
> cast to org.dcm4che.util.UIDGenerator
> while adding dicom header to a jpeg and save the image as DICOM.The code
> snippet as well as
> exception stacktrace is as follows:
> I am using Tudor Dicom Tools and dcm4che.jar.

Seems you are using an old version of the DICOM Tools? We are using the
dcm4che2 libs since some time and have done a lot of changes and new
features.
The code for exporting has although changed a bit:

DicomExporter exporter = new DicomExporter();
File dcmFile = new File("/home/hermenj/jhermen.dcm");
ImagePlus ip = new ImagePlus("/home/hermenj/img.jpg");

DicomObject dObj = exporter.createHeader(ip, true, true, true);

// if wanted, set additional tags...
DicomAnonymizer.addTag(dObj, Tag.PatientName, "Testpatient");

exporter.writeImage(dObj, ip, dcmFile);

Please try the latest version from
http://santec.tudor.lu/project/optimage/dicom/start and be sure to exchange
all dcm4che libs with the ones from the new dicom-tools.

Greets
        Johannes


-----------------------------------------------------------------
Johannes Hermen  -  Ingenieur de Recherche
[hidden email]
-----------------------------------------------------------------
CRP Henri Tudor  http://www.santec.tudor.lu
29, Avenue John F. Kennedy
L-1855 Luxembourg
-----------------------------------------------------------------