2016-03-31 101 views
0

我想從Windows平臺上使用java的dicom圖像提取圖像和元數據。我是dcm4che的新手。 我的代碼是使用java從DICOM圖像中提取圖像和元數據

我收到錯誤

Exception in thread "main" java.lang.NoClassDefFoundError:  org/dcm4che2/image/PartialComponentSampleModel 
at org.dcm4che2.imageioimpl.plugins.dcm.DicomImageReaderSpi.createReaderInstance(DicomImageReaderSpi.java:146) 
at javax.imageio.spi.ImageReaderSpi.createReaderInstance(ImageReaderSpi.java:320) 
at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:529) 
at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:513) 
at miec.extraction.extraction.extractionD(extraction.java:32) 
at miec.MIEC.main(MIEC.java:46) 
Caused by: java.lang.ClassNotFoundException: org.dcm4che2.image.PartialComponentSampleModel 
at java.net.URLClassLoader$1.run(URLClassLoader.java:372) 
at java.net.URLClassLoader$1.run(URLClassLoader.java:361) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.net.URLClassLoader.findClass(URLClassLoader.java:360) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
... 6 more 

請幫我...這所有jar文件,我應該有..

+0

添加你的代碼 – Pavya

+0

你是如何得到這個錯誤的? – Pierre

回答

0

使用PixelMed
下面的例子

import com.pixelmed.dicom.Attribute; 
import com.pixelmed.dicom.AttributeList; 
import com.pixelmed.dicom.AttributeTag; 
import com.pixelmed.dicom.TagFromName; 
import com.pixelmed.display.SourceImage; 


public class DisplayImageTagsToConsole { 

private static AttributeList list = new AttributeList(); 
public static void readDcmFile() { 
    String dicomFile = "E:\\eye\\demo12.dcm"; 

    try { 
     list.read(dicomFile); 
     System.out.println("Patient Name:" + getTagInformation(TagFromName.PatientName)); 
      System.out.println("Patient ID:" + getTagInformation(TagFromName.PatientID)); 
      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)); 

    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
} 

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