Dashboard > dcm4che-2.x > ... > Working with DICOM files > Reading DICOM files
Reading DICOM files Log In | Sign Up   View a printable version of the current page.

Added by Damien Evans , last edited by Brian Alexander on May 23, 2008  (view change) show comment
Labels: 
(None)

Introduction

DICOM files can be read from Java java.io.InputStream objects, and java.io.File objects. This is done through the org.dcm4che2.io.DicomInputStream class, which extends java.io.FilterInputStream. The DICOM file is typically read into a org.dcm4che2.data.DicomObject implementation. For example:

DicomObject dcmObj;
DicomInputStream din = null;
try {
    din = new DicomInputStream(new File("image.dcm"));
    dcmObj = din.readDicomObject();
}
catch (IOException e) {
    e.printStackTrace();
    return;
}
finally {
    try {
        din.close();
    }
    catch (IOException ignore) {
    }
}

The DicomObject may then be worked with.

When creating DicomInputStream objects, the Transfer Syntax of the DICOM file will be extrapolated from the file contents. There may be cases where you need to read a raw dataset or when you already know the Transfer Syntax of the DICOM object. In these cases case you should use one of the constructors that specifies the Transfer Syntax as an argument. For example:

din = new DicomInputStream(new BufferedInputStream(new FileInputStream("image.dcm")), TransferSyntax.ImplicitVRLittleEndian);



This page has been viewed 6193 times.

Powered by a free Atlassian Confluence Open Source Project License granted to dcm4che. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators