How to Insert informations into image dcm?

554 views
Skip to first unread message

Thales Castro

unread,
Sep 28, 2016, 9:22:34 AM9/28/16
to dcm4che
Hi, I have an application in which the use jpg2dcm to convert hundreds of jpg images to dcm. I do it using C and openmp, but now the problem is another: insert informations into image dcm, as patient ID, patient's name, etc ... The idea of create an xml file is good (jpg2dcm -c jpg2dcm.xml image.jpg image.dcm), but I don't know where to start. Would someone give me a suggestion and an example of xml I can use? Thanks!!

Dimitri Pianeta

unread,
Sep 28, 2016, 10:31:57 AM9/28/16
to dcm4che

There are two methods for creating a new image DICOM.
- Use code source of jpg2dcm is used code java with the tag. (for example in my class Jpgdcm.java) In my class, in syntax following  " dicom.setString(Tag.SpecificCharacterSet, VR.CS, "ISO_IR 100");" creatre a new tag.
- Or using a file xml following  in use my code XmlDcm.java






Jpgdcm.java
XmlDcm.java

Thales Castro

unread,
Sep 28, 2016, 12:30:42 PM9/28/16
to dcm...@googlegroups.com
I'm sorry, Dimitri! My inglish is not very well, maybe I was not clear! I meant tha already can convert jpg images to dcm with command jpg2dcm (https://github.com/dcm4che/dcm4che/tree/master/dcm4che-tool/dcm4che-tool-jpg2dcm), what is missing is to enter the information therein. I believe that with the command "jpg2dcm -c jpg2dcm.xml image.jpg image.dcm" I can, but I don't know how to be this xml file. Or not is possible this way? What I need is of an example of file xml. Sorry if I was unclear! 

fleetwoodfc

unread,
Sep 28, 2016, 6:34:12 PM9/28/16
to dcm4che

Thales Castro

unread,
Sep 29, 2016, 8:34:19 AM9/29/16
to dcm4che
Hi, fleetwoodfc. Thanks for the help! But I have this error when I run the command ./dcm4che/bin/jpg2dcm -c jpg2dcm.xml input.jpg out.dcm:

Exception in thread "main" java.lang.IllegalArgumentException: Unknown Tag Name: <
at org.dcm4che2.data.Tag.forName(Tag.java:56)
at org.dcm4che2.data.Tag.toTag(Tag.java:64)
at org.dcm4che2.data.Tag.toTagPath(Tag.java:87)
at org.dcm4che2.tool.jpg2dcm.Jpg2Dcm.convert(Jpg2Dcm.java:203)
at org.dcm4che2.tool.jpg2dcm.Jpg2Dcm.main(Jpg2Dcm.java:374)

I don't know java and I don't have a ideia what can be. 

Dimitri Pianeta

unread,
Sep 29, 2016, 10:01:19 AM9/29/16
to dcm4che
This error come in the name one or several TAGs because the methods forName return hexa of tag.

fleetwoodfc

unread,
Sep 29, 2016, 2:35:54 PM9/29/16
to dcm4che
Yes you will get this error if you use the dcm4che2 tool - use the dcm4che3 version with the jpg2dcm.xml file (the dcm4che2 version uses a .properties file).

Thales Castro

unread,
Sep 30, 2016, 1:53:07 PM9/30/16
to dcm4che
Thank you! It worked. :D

Alan933

unread,
Jan 2, 2018, 4:14:41 PM1/2/18
to dcm4che
I am having same problem. Can you please explain why a .properties file causes this error?
Reply all
Reply to author
Forward
0 new messages