Reputation: 8018
I am trying to follow the tutorial at
to read dicom files. 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/
Upvotes: 0
Views: 1445
Reputation: 1677
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. It has nothing to do with the Pixelmed library per se. This answer lists some good options:
Using ImageIO to convert from JPEG2000 to 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.
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.
Upvotes: 1