Hi to the group!
i am converting my DICOM images to Jpeg using Dcm2Jpg utility class, however recently i faced the case where i need to convert some compressed DICOM images to Jpeg.
My code:
public void convertDcmToJpeg(File dcmObjFile, File jpgFile) throws IOException {
Dcm2Jpg dcm2Jpg = new Dcm2Jpg();
log.info("converting: " + dcmObjFile.getName() + " to jpeg: " + jpgFile.getName());
try {
dcm2Jpg.convert(dcmObjFile, jpgFile);
}
...
}
where Dcm2Jpg is the original dcm4che utility class. The process fails on the two red/bold lines:
public void convert(File src, File dest) throws IOException {
log.info("file to be created: " + dest.getAbsolutePath()); Iterator<ImageReader> iter = ImageIO.getImageReadersByFormatName("DICOM");
ImageReader reader = iter.next();
DicomImageReadParam param =
(DicomImageReadParam) reader.getDefaultReadParam();
param.setWindowCenter(center);
param.setWindowWidth(width);
param.setVoiLutFunction(vlutFct);
param.setPresentationState(prState);
param.setPValue2Gray(pval2gray);
param.setAutoWindowing(autoWindowing);
ImageInputStream iis = ImageIO.createImageInputStream(src);
BufferedImage bi;
try {
reader.setInput(iis, false);
bi = reader.read(frame - 1, param);
if (bi == null) {
log.info("\nError: " + src + " - couldn't read!"); return;
}
encodeByImageIO(bi, dest);
} finally {
CloseUtils.safeClose(iis);
}
}
and the exception i get:
org.dcm4che2.data.ConfigurationError: No Image Reader of class com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader available for format:jpeg
at org.dcm4che2.imageio.ImageReaderFactory.getReaderForTransferSyntax(ImageReaderFactory.java:99)
at org.dcm4che2.imageioimpl.plugins.dcm.DicomImageReader.initCompressedImageReader(DicomImageReader.java:410)
at org.dcm4che2.imageioimpl.plugins.dcm.DicomImageReader.initImageReader(DicomImageReader.java:395)
at org.dcm4che2.imageioimpl.plugins.dcm.DicomImageReader.read(DicomImageReader.java:636)
at b.e.a(Dcm2Jpg.java:179)
at l.i.a(ProcessDicomFiles.java:2020)
at l.i.b(ProcessDicomFiles.java:1992)
at l.i.j(ProcessDicomFiles.java:1626)
at g.a.execute(MainJob.java:87)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
So, i am wondering how could i convert to JPEG compressed DICOM images. Do i have first have to de-compressed using the utility class Dcm2Dcm? If yes is there any examples... Which method of this class can be used for de-compressing DICOM images?
Any other parameters or details about dicom image decompression that i would need to know about?
Thanks in advace for you time!