import ij.plugin.*; import ij.*; import ij.io.*; import ij.process.ImageProcessor; import ij.process.TypeConverter; import java.io.*; import javax.swing.*; import javax.swing.filechooser.*; import java.util.Arrays; import java.util.Vector; /* Select a list of files and open them all as a stack IMPORTANT: - only jpg, png, gif and tiff will be loaded into an RGB stack - only first slice of multi-tif and multi-gif images is opened This plugin by Albert Cardona (albert@pensament.net ) at July 12 2003 modified from File_Opener.java available at http://rsb.info.nih.gov/ij/plugins NOTE: only first file of list will open in some Java Virtual Machines NOTE: in Mac OS X, multiple files open only if consecutive in selection */ /** Uses the JFileChooser from Swing to open one or more images. */ public class Open_as_Stack implements PlugIn { static File dir; public void run(String arg) { openFilesAsStack(); IJ.register(Open_as_Stack.class); } public void openFilesAsStack() { JFileChooser fc = null; try {fc = new JFileChooser();} catch (Throwable e) {IJ.error("This plugin requires Java 2 or Swing."); return;} fc.setMultiSelectionEnabled(true); if (dir==null) { String sdir = OpenDialog.getDefaultDirectory(); if (sdir!=null) dir = new File(sdir); } if (dir!=null) fc.setCurrentDirectory(dir); int returnVal = fc.showOpenDialog(IJ.getInstance()); if (returnVal!=JFileChooser.APPROVE_OPTION) return; File[] files = fc.getSelectedFiles(); if (files.length==0) { // getSelectedFiles does not work on some JVMs files = new File[1]; files[0] = fc.getSelectedFile(); } String supported_image_types = "tif jpg gif png"; Vector v_files = new Vector(); for (int n=0; n largest_width) largest_width = all_width[k]; if (all_height[k] > largest_height) largest_height = all_height[k]; } ImageStack istack = new ImageStack(largest_width, largest_height); //int centerx, centery; for (int i=0; i