java 解析Dicom 文件

項目使用中需要解析下載過來的Dicom文件,然後根據固定的層級結構給文件分目錄。以下是代碼:

/**
 * <p>
 * Title: GetDicomTag
 * </p>
 * 
 * <p>
 * Description:解析DICOM文件獲取屬性值
 * </p>
 * 
 * @author yangzhen
 * @date 2018年4月2日
 */
public class GetDicomTag {

    public static String getDicomTag(File file, int TagParam) {
        InputStream inputStream = null;
        DicomInputStream dicomInputStream = null;
        String result = "";
        try {
            inputStream = FileUtils.openInputStream(file);
            dicomInputStream = new DicomInputStream(inputStream);
            DicomObject dicomObject = dicomInputStream.readDicomObject();

            if (dicomObject != null) {

                result = dicomObject.getString(TagParam);

                return result;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            try {
                if (dicomInputStream != null) {
                    dicomInputStream.close();
                }
                if (inputStream != null) {
                    inputStream.close();
                }
            } catch (IOException ex) {
                // logger
            }
        }
        return result;
    }

根據Dicom的Tag屬性獲取想要的值,Tag文件在這裏下載

https://download.csdn.net/download/wuyu5649/10713109

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章