![]() |
![]()
| ![]() |
![]()
NAMEimg2dcm - Convert standard image formats into DICOM format SYNOPSISimg2dcm [options] imgfile-in... dcmfile-out DESCRIPTIONThe img2dcm tool serves as a conversion tool from a standard image format like JPEG (including JPEG-LS) or BMP to DICOM. Different output SOP Classes can be selected. The additional information (regarding patients, series, etc.) stored in the DICOM output file can be extracted from other DICOM files which serve as a 'template' for the resulting DICOM object. img2dcm can also be configured to invent missing DICOM type 1 and type 2 attributes to work even without any template dataset. PARAMETERSimgfile-in image input filename dcmfile-out DICOM output filename ("-" for stdout) OPTIONSgeneral options
input optionsgeneral: processing optionsattribute checking: output optionstarget SOP class: NOTESAttribute SourcesFor converting a general image format into DICOM format, the img2dcm application may be fed with some additional input for filling mandatory (and optional) attributes in the new DICOM file like patient, study and series information. This information can be collected using different approaches, which can be combined and are applied to the result file in the following order:
UIDsNew Study and Series Instance UIDs are generated if necessary after applying the --study-from and --series-from options. If Study Instance UID or Series Instance UID are not present after these steps, they are newly generated, independently from each other. A contrary behavior is chosen for the SOP Instance UID that one could expect to be taken over when using the --dataset-from or --dataset-from-xml option. This is not the case, the SOP Instance UID is not copied to the new object. This should be the desirable behavior for most use cases. However, if a certain SOP Instance UID should be inserted into the new object, the --key option should be used. Input TemplatesFor supporting the conversion into DICOM, img2dcm comes with some pre-defined templates which can be used for the --dataset-from option (see sample files SC.dump and VLP.dump). These templates should be filled with the desired values and then must be dumped (converted) to a DICOM file before actually being used with img2dcm. Use dump2dcm to convert the dump to DICOM. Example:
For Ophthalmic Photography images, XML templates are provided (see sample file OP_template_utf_8.xml and OP_template_latin_1.xml). It is possible to use any DICOM file as a template. Please note that the complete DICOM dataset is imported; hence, it should be assured that only attributes are present which should be part of the constructed DICOM object. The SOP Class UID and the Pixel Data attributes (including attributes like Rows, Columns etc.) are not copied but replaced by img2dcm during conversion. Multiframe ImagesIt is possible to convert multiple input files into one DICOM multiframe image if the selected DICOM SOP class supports multiframe. In particular, the Multi-frame Secondary Capture SOP Classes support this feature. They are selected through the --new-sc command line option. Character SetsWhen an input template is loaded using --dataset-from or --dataset-from-xml, the specific character set of that template is used for the generated DICOM file. If the --study-from or --series-from options are used additionally, img2dcm will try to convert the character set of these attributes to that of the template, and will report an error if that is not possible. If the --study-from or --series-from options are used without a template, the specific character set of this source is used for the generated DICOM file. Any keys specified on the command line with the --key option are treated as raw bytes and override any attributes that may already be present due to a template or study/series file. Therefore, care should be taken to not specify a specific character set on the command line if one might be loaded from another file. It is also the user's responsibility to ensure that attribute values specified on the command line use the correct encoding, as no conversion will take place before the values are stored in the DICOM file. Input PluginsThe img2dcm application currently supports the JPEG, JPEG-LS and the BMP image format as input. JPEG Input PluginFor JPEG, the original JPEG from the source file is not decoded but extracted and slightly transformed (e.g. JFIF header is cut off) to allow fast conversion of even big JPEG files without the need of decoding and re-encoding. The JPEG plugin chooses the necessary output transfer syntax automatically depending on the actual encoding of the data inside the JPEG file. Therefore, the following Transfer Syntaxes (and their corresponding JPEG encodings) are used by the JPEG plugin:
Color and grayscale images are supported. The support for the Extended JPEG Transfer Syntax can be disabled (--disable-ext option) as well as the support for the (retired) Progressive JPEG Transfer Syntax (--disable-progr option). JPEG lossless encoding as well as any arithmetic or hierarchical JPEG encoding modes are not supported by the plugin. JFIF (JPEG File Interchange Format) information facilitates optional APPn markers in a JPEG file. Many digital cameras do not integrate such JFIF information into the JPEG output they create. For example, JFIF contains information about the pixel aspect ratio of the compressed image. If you want the img2dcm application to insist on a JFIF header in the JPEG stream, you can use the option --insist-on-jfif which will abort if no JFIF information can be found. By default, missing JFIF information is ignored. For DICOM it is kind of a 'gray zone', whether the integration of JFIF (or any other APPn) data into the DICOM object's internal JPEG stream is allowed or not. However, the most reliable approach is to cut those markers and their information off the JPEG stream. This approach is also taken by the img2dcm application. By default, all APPn markers are cut off from the original JPEG stream. However, if you want to keep other APPn markers than JFIF (e.g. EXIF information) inside the DICOM stream, the option --keep-appn does the trick. It should also be slightly faster than cutting off APPn information, because it is not necessary to scan the whole JPEG stream for such data. As stated before, JFIF information is always removed by img2dcm. However, when using this option, the APP2 marker is retained, but img2dcm does not create an equivalent ICC Profile (0028,2000) attribute. JPEG-LS Input PluginThe JPEG-LS plugin has been integrated directly into the main JPEG plugin. There is no need for the user to explicitly state in advance if input is JPEG or JPEG-LS. For JPEGL-LS, the original JPEG-LS from the source file is not decoded but extracted and slightly transformed (e. g. APP8 marker is cut off) to allow fast conversion of even big JPEG-LS files without the need of decoding and re-encoding. The JPEG-LS plugin chooses the necessary output transfer syntax automatically depending on the actual encoding of the data inside the JPEG-LS file. Therefore, the following Transfer Syntaxes (and there corresponding JPEG-LS encodings) are used by the JPEG-LS plugin:
Color and grayscale images are supported. CP-1843 enforce that the value of Planar Configuration (0028,0006) is irrelevant since the manner of encoding components is specified in the JPEG-LS bit stream as component, line or sample interleaved, hence it shall be set to 0. Since no color transformation specific for JPEG-LS is currently defined in DICOM, it is assumed that the JPEG-LS stream is encoded in RGB color space. For DICOM it is clear that SPIFF header should not be present in the DICOM object's internal JPEG-LS stream. The plugin will simply rejects any input JPEG-LS file containing a SPIFF header at marker APP8. By default, all APPn markers are cut off from the original JPEG-LS stream. However, if you want to keep APPn markers (e.g. APP8/HP color transform information, aka 'mrfx') inside the DICOM stream, the option --keep-appn does the trick. Pay attention that the plugin will check the actual color transform specified in the APP8/HP marker. Since DICOM does not allow any color transform to be specified in the APP8 marker, only a value of 0 (no color transform) is accepted. BMP Input Pluginimg2dcm supports BMP as input format. However, so far only the most common BMP images are supported. In particular, BMP images which use bit fields or run length encoding will be rejected. Such images are uncommon. Input images will either be converted into a DICOM image with RGB color model and a bit depth of 24, or into an image with MONOCHROME2 color model an 8 bits per pixel. There are no specific options for fine-tuning BMP format conversion. Output PluginsThe desired output SOP Class can be selected on the command line. Currently, export plugins for the Secondary Capture Image SOP Class (default, option -sc), the Multi-frame Secondary Capture Image SOP Classes (option -nsc), Visible Light Photographic Image SOP Class (option -vl), and the Ophthalmic Photography Image SOP Classes (option -oph) are available. Please note that the first one is deprecated according to the DICOM standard but is selected as a default because it is widely supported. Future versions of img2dcm might provide further output plugins for other SOP Classes. For the new Secondary Capture SOP Classes, it is not possible to specify which specific SOP Class should be used for output. That is because these new SOP classes are differentiated from each other by color depth (1/8/16) and the fact whether the image is black/white or color. That is why img2dcm decides during conversion, which output SOP Class is suitable for a given source image. EXAMPLESHere are some examples that show how the img2dcm application can be used.
LOGGINGThe level of logging output of the various command line tools and underlying libraries can be specified by the user. By default, only errors and warnings are written to the standard error stream. Using option --verbose also informational messages like processing details are reported. Option --debug can be used to get more details on the internal activity, e.g. for debugging purposes. Other logging levels can be selected using option --log-level. In --quiet mode only fatal errors are reported. In such very severe error events, the application will usually terminate. For more details on the different logging levels, see documentation of module 'oflog'. In case the logging output should be written to file (optionally with logfile rotation), to syslog (Unix) or the event log (Windows) option --log-config can be used. This configuration file also allows for directing only certain messages to a particular output stream and for filtering certain messages based on the module or application where they are generated. An example configuration file is provided in <etcdir>/logger.cfg. COMMAND LINEAll command line tools use the following notation for parameters: square brackets enclose optional values (0-1), three trailing dots indicate that multiple values are allowed (1-n), a combination of both means 0 to n values. Command line options are distinguished from parameters by a leading '+' or '-' sign, respectively. Usually, order and position of command line options are arbitrary (i.e. they can appear anywhere). However, if options are mutually exclusive the rightmost appearance is used. This behavior conforms to the standard evaluation rules of common Unix shells. In addition, one or more command files can be specified using an '@' sign as a prefix to the filename (e.g. @command.txt). Such a command argument is replaced by the content of the corresponding text file (multiple whitespaces are treated as a single separator unless they appear between two quotation marks) prior to any further evaluation. Please note that a command file cannot contain another command file. This simple but effective approach allows one to summarize common combinations of options/parameters and avoids longish and confusing command lines (an example is provided in file <datadir>/dumppat.txt). ENVIRONMENTThe img2dcm utility will attempt to load DICOM data dictionaries specified in the DCMDICTPATH environment variable. By default, i.e. if the DCMDICTPATH environment variable is not set, the file <datadir>/dicom.dic will be loaded unless the dictionary is built into the application (default for Windows). The default behavior should be preferred and the DCMDICTPATH environment variable only used when alternative data dictionaries are required. The DCMDICTPATH environment variable has the same format as the Unix shell PATH variable in that a colon (':') separates entries. On Windows systems, a semicolon (';') is used as a separator. The data dictionary code will attempt to load each file specified in the DCMDICTPATH environment variable. It is an error if no data dictionary can be loaded. FILES<datadir>/SC.dump - Sample dump file for Secondary
Capture images
SEE ALSOdcm2pnm(1), dcmj2pnm(1), dump2dcm(1), dcmconv(1), dcmodify(1), dcm2xml(1) COPYRIGHTCopyright (C) 2007-2024 by OFFIS e.V., Escherweg 2, 26121 Oldenburg, Germany.
|