Friedrich-Alexander-Universität
Friedrich-Alexander-Universität
Stanford Radiology

Read Image Data

CONRAD support to read any file type that is supported by ImageJ. Reading from hard disk is done via the ImageJ API. The ImageJ containers can then be easily wrapped to CONRAD containers. This example is found in the source tree in package edu.stanford.rsl.tutorial.basics in ReadImageDataFromFile.java

Code Example

public class ReadImageDataFromFile {

 /**
 * Main routine for this example.
 * @param args
 */
 public static void main(String[] args) {
  try {
    // we need ImageJ in the following
    new ImageJ();
    // locate the file
    // here we only want to select files ending with ".bin". This will open them as "Dennerlein" format.
    // Any other ImageJ compatible file type is also OK.
    // new formats can be added to HandleExtraFileTypes.java
    String filenameString = FileUtil.myFileChoose(".bin", false);
    // call the ImageJ routine to open the image:
    ImagePlus imp = IJ.openImage(filenameString);
    // Convert from ImageJ to Grid3D. Note that no data is copied here.
    // The ImageJ container is only wrapped. Changes to the Grid will also affect the ImageJ ImagePlus.
    Grid3D impAsGrid = ImageUtil.wrapImagePlus(imp);
    // Display the data that was read from the file.
    impAsGrid.show("Data from file");
   } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
  }
}