Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting DICOM image to jpeg image
    primarykey
    data
    text
    <p>My code is </p> <pre><code>import java.awt.image.BufferedImage; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.Iterator; import javax.imageio.ImageIO; import javax.imageio.ImageReader; import javax.imageio.stream.ImageInputStream; import org.dcm4che2.imageio.plugins.dcm.DicomImageReadParam; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGImageEncoder; public class DicomToJpeg { public static void main(String args[]) throws IOException, Exception { dicomToJpeg("d:/F74AFBC7"); } public static void dicomToJpeg(String args) throws IOException, Exception { // TODO Auto-generated method stub try { File myDicomFile = new File(args); BufferedImage myJpegImage = null; Iterator&lt;ImageReader&gt; iter = ImageIO.getImageReadersByFormatName("DICOM"); ImageReader reader = (ImageReader) iter.next(); DicomImageReadParam param = null; try{ param = (DicomImageReadParam) reader.getDefaultReadParam(); } catch (Exception e) { e.printStackTrace(); } ImageInputStream iis=ImageIO.createImageInputStream(myDicomFile); reader.setInput(iis, false); myJpegImage = reader.read(0, param); iis.close(); if (myJpegImage == null) { System.out.println("\nError: couldn't read dicom image!"); return; } File myJpegFile = new File("d:/demo.jpg"); OutputStream output = new BufferedOutputStream(new FileOutputStream(myJpegFile)); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(output); encoder.encode(myJpegImage); System.out.println("Image Create successufully"); output.close(); } catch(IOException e){ System.out.println("\nError: couldn't read dicom image!"+ e.getMessage()); return; } } } </code></pre> <p>When i execute in java project using eclipse it work fine... But when i execute using web application and in this i call it from controller page like</p> <blockquote> <p>DicomToJpeg.dicomToJpeg("d:/F74AFBC7");</p> </blockquote> <p>then it gives error like...</p> <pre><code>java.util.NoSuchElementException at javax.imageio.spi.FilterIterator.next(Unknown Source) at javax.imageio.ImageIO$ImageReaderIterator.next(Unknown Source) at javax.imageio.ImageIO$ImageReaderIterator.next(Unknown Source) at com.lifecare.controller.DicomToJpeg.dicomToJpeg(DicomToJpeg.java:32) </code></pre> <p>How to solve this error please help me....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload