pixelmed:无法读取dicom文件

时间:2018-03-09 21:08:09

标签: java dicom pixelmed

我正在尝试按照

中的教程

https://saravanansubramanian.com/Saravanan/Articles_On_Software/Entries/2014/10/6_DICOM_Basics_-_Extracting_Image_Pixel_Data.html

阅读dicom文件。这是我运行的一些代码

private static AttributeList list = new AttributeList();
    public static void main(String[] args) {
        String dicomFile = "/path/to/CT1_J2KR.dcm";

        try {
            list.read(dicomFile);
            System.out.println("Transfer Syntax:" + getTagInformation(TagFromName.TransferSyntaxUID));
            System.out.println("SOP Class:" + getTagInformation(TagFromName.SOPClassUID));
            System.out.println("Modality:" + getTagInformation(TagFromName.Modality));
            System.out.println("Samples Per Pixel:" + getTagInformation(TagFromName.SamplesPerPixel));
            System.out.println("Photometric Interpretation:" + getTagInformation(TagFromName.PhotometricInterpretation));
            System.out.println("Pixel Spacing:" + getTagInformation(TagFromName.PixelSpacing));
            System.out.println("Bits Allocated:" + getTagInformation(TagFromName.BitsAllocated));
            System.out.println("Bits Stored:" + getTagInformation(TagFromName.BitsStored));
            System.out.println("High Bit:" + getTagInformation(TagFromName.HighBit));
            SourceImage img = new com.pixelmed.display.SourceImage(list);
            System.out.println("Number of frames " + img.getNumberOfFrames());
            System.out.println("Width " + img.getWidth());//all frames will have same width
            System.out.println("Height " + img.getHeight());//all frames will have same height  
            System.out.println("Is Grayscale? " + img.isGrayscale());
            System.out.println("Pixel Data present:" + (list.get(TagFromName.PixelData) != null));
            OtherWordAttribute pixelAttribute = (OtherWordAttribute)(list.get(TagFromName.PixelData));
            //get the 16 bit pixel data values
            short[] data = pixelAttribute.getShortValues();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static String getTagInformation(AttributeTag attrTag) {
        return Attribute.getDelimitedStringValuesOrEmptyString(list, attrTag);
    }

但是

list.read(dicomFile);

我得到了

    com.pixelmed.dicom.DicomException: No reader for JPEG2000 available for Transfer Syntax 1.2.840.10008.1.2.4.91
    at com.pixelmed.dicom.CompressedFrameDecoder.selectReaderFromCodecsAvailable(CompressedFrameDecoder.java:290)
    at com.pixelmed.dicom.AttributeList.read(AttributeList.java:913)
    at com.pixelmed.dicom.AttributeList.read(AttributeList.java:1166)
    at com.pixelmed.dicom.AttributeList.read(AttributeList.java:1284)
    at com.pixelmed.dicom.AttributeList.read(AttributeList.java:1365)
    at com.pixelmed.dicom.AttributeList.read(AttributeList.java:1333)
    at com.pixelmed.dicom.AttributeList.read(AttributeList.java:1486)
    at com.ibm.whi.breastadvisor.controller.BCADicomParser.parse(BCADicomParser.java:47)
    at com.ibm.whi.breastadvisor.controller.test.BCADicomParserUnitTest.dicomTest(BCADicomParserUnitTest.java:20)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

我该如何解决这个问题?另外,这是我如何得到像素罐

http://www.dclunie.com/pixelmed/software/20170524_current/

1 个答案:

答案 0 :(得分:1)

我一直在努力解决同样的问题,据我所知,根本问题是JDK不支持JPEG2000开箱即用。它与Pixelmed库本身无关。这个答案列出了一些不错的选择:

Using ImageIO to convert from JPEG2000 to PNG

最好的长期解决方案可能是使用OpenJPEG项目,但对我来说,将本机库捆绑为项目的一部分会非常麻烦。

我通过使用jai-imageio-jpeg2000库(简单地将其添加为Maven依赖项,不需要更改代码)来实现它,但是在他们的GitHub页面上列出的许可免责声明可能对您来说是一个问题。