简体   繁体   English

pixelmed : 无法读取 dicom 文件

[英]pixelmed : Cannot read dicom file

I am trying to follow the tutorial at我正在尝试按照教程进行操作

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

to read dicom files.读取 dicom 文件。 Here is some code i run这是我运行的一些代码

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);
    }

but at但在

list.read(dicomFile);

i get我明白了

    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)

how do i fix this?我该如何解决? Also, here is how i got the pixelmed jar另外,这是我如何获得像素化罐子的

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

I have been struggling with the same issue and as far as I can tell the root problem is that the JDK has no support for JPEG2000 out-of-the box.我一直在为同样的问题苦苦挣扎,据我所知,根本问题是 JDK 不支持 JPEG2000 开箱即用。 It has nothing to do with the Pixelmed library per se.它与 Pixelmed 库本身无关。 This answer lists some good options:这个答案列出了一些不错的选择:

Using ImageIO to convert from JPEG2000 to PNG 使用 ImageIO 将 JPEG2000 转换为 PNG

The best long-term solution would probably be to use the OpenJPEG project, but for me it would be too cumbersome to bundle native libraries as part of my project.最好的长期解决方案可能是使用 OpenJPEG 项目,但对我来说,将本机库作为项目的一部分捆绑在一起太麻烦了。

I got it to work by using the jai-imageio-jpeg2000 library (simply added it as Maven dependency, no code changes required), but the licensing disclaimer listed on their GitHub page might be an issue for you.我通过使用jai-imageio-jpeg2000库(只是将其添加为 Maven 依赖项,无需更改代码)使其工作,但他们的 GitHub 页面上列出的许可免责声明可能对您来说是个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM