public void testSkeletonize2() {
   ImagePlus t = IJ.openImage(WORM1);
   SkeletonizeWrapper sw = new SkeletonizeWrapper();
   sw.skeletonize(t);
   IJ.save(sw.getLspImage(), WORM1OUT);
   IJ.save(sw.getSkeletonImage(), SKELOUT2);
 }
  @Test
  public final void testDilationHilbertCurveC26() {
    String fileName = getClass().getResource("/files/hilbert3d.tif").getFile();
    ImagePlus imagePlus = IJ.openImage(fileName);

    assertNotNull(imagePlus);

    assertTrue(imagePlus.getStackSize() > 0);

    ImageStack mask = imagePlus.getStack();

    int width = mask.getWidth();
    int height = mask.getHeight();
    int depth = mask.getSize();
    int bitDepth = mask.getBitDepth();
    ImageStack marker = ImageStack.create(width, height, depth, bitDepth);

    marker.setVoxel(3, 0, 0, 255);

    GeodesicReconstruction3DHybrid0Gray8 algo = new GeodesicReconstruction3DHybrid0Gray8();
    algo.setConnectivity(26);
    algo.verbose = false;

    ImageStack result = algo.applyTo(marker, mask);

    for (int z = 0; z < depth; z++) {
      for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
          assertEquals(result.getVoxel(x, y, z), mask.getVoxel(x, y, z), .01);
        }
      }
    }
  }
  @Test
  public final void testDilationCochleaVolumeC6() {
    String fileName = getClass().getResource("/files/bat-cochlea-volume.tif").getFile();
    ImagePlus imagePlus = IJ.openImage(fileName);

    assertNotNull(imagePlus);

    assertTrue(imagePlus.getStackSize() > 0);

    ImageStack mask = imagePlus.getStack();
    // Ensure regularity of the mask
    mask = Morphology.opening(mask, CubeStrel.fromRadius(1));

    int width = mask.getWidth();
    int height = mask.getHeight();
    int depth = mask.getSize();
    int bitDepth = mask.getBitDepth();
    ImageStack marker = ImageStack.create(width, height, depth, bitDepth);

    marker.setVoxel(20, 80, 50, 255);

    GeodesicReconstruction3DHybrid0Gray8 algo = new GeodesicReconstruction3DHybrid0Gray8();
    algo.setConnectivity(6);
    algo.verbose = false;

    ImageStack result = algo.applyTo(marker, mask);

    for (int z = 0; z < depth; z++) {
      for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
          assertEquals(result.getVoxel(x, y, z), mask.getVoxel(x, y, z), .01);
        }
      }
    }
  }
  @Test
  public final void testApplyTo() {
    GeodesicReconstructionByDilation3DGray8 algo = new GeodesicReconstructionByDilation3DGray8();

    String fileName = getClass().getResource("/files/bat-cochlea-volume.tif").getFile();
    ImagePlus imagePlus = IJ.openImage(fileName);
    assertNotNull(imagePlus);

    assertTrue(imagePlus.getStackSize() > 0);

    ImageStack mask = imagePlus.getStack();
    int width = mask.getWidth();
    int height = mask.getHeight();
    int depth = mask.getSize();
    int bitDepth = mask.getBitDepth();
    ImageStack marker = ImageStack.create(width, height, depth, bitDepth);

    marker.setVoxel(20, 80, 50, 255);

    ImageStack result = algo.applyTo(marker, mask);

    for (int z = 0; z < depth; z++) {
      for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
          assertEquals(result.getVoxel(x, y, z), mask.getVoxel(x, y, z), .01);
        }
      }
    }
  }
 /** Test of skeletonize method, of class SkeletonizeWrapper. */
 public void testSkeletonize() {
   System.out.println("skeletonize");
   ImagePlus threshold = IJ.openImage(THRESHOLD);
   threshold.getProcessor().invert();
   ArrayList<Roi> rois = null;
   SkeletonizeWrapper instance = new SkeletonizeWrapper();
   instance.skeletonize(threshold);
   IJ.save(threshold, SKELOUT);
   // TODO review the generated test code and remove the default call to fail.
   //        fail("The test case is a prototype.");
 }
Пример #6
0
 private ImagePlus openCachedImage(String url) {
   if (url == null || !url.contains("ij/images")) return null;
   String ijDir = IJ.getDirectory("imagej");
   if (ijDir == null) return null;
   int slash = url.lastIndexOf('/');
   File file = new File(ijDir + "samples", url.substring(slash + 1));
   if (!file.exists()) return null;
   if (url.endsWith(".gif")) // ij.plugin.GIF_Reader does not correctly handle inverting LUTs
   return openJpegOrGif(file.getParent() + File.separator, file.getName());
   return IJ.openImage(file.getPath());
 }
Пример #7
0
  public static void main(final String... args) throws FileNotFoundException {
    AAP_wStimulus aap = new AAP_wStimulus();
    String path;
    try {
      path = "D:\\# Projects (Noam)\\# SLITE\\# DATA\\AAP 1.1.0\\"; // LAB
      ImagePlus imp_test = IJ.openImage(path + "TEXT_20msON_10Hz_SLITE_2.tif");
      if (imp_test == null) {
        throw new FileNotFoundException("Your not in Lab....");
      }
    } catch (FileNotFoundException error) {
      path =
          "C:\\Users\\noambox\\Dropbox\\# Graduate studies M.Sc\\# SLITE\\ij - plugin data\\"; // HOME
    }

    aap.imp_r = IJ.openImage(path + "TEXT_20msON_10Hz_SLITE_2.tif"); // DEBUG
    aap.imp_s = AVI_Reader.open(path + "OLEDstim_ON0.02_OFF9.98_FlashingText 21.avi", true);
    aap.imp_r.show();
    aap.imp_s.show();
    String argv = "";
    aap.run(argv);
  }
Пример #8
0
 public DataImporter(final String resultsFilePath, final boolean readWeights) {
   super();
   final ImageStack file = IJ.openImage(resultsFilePath).getImageStack();
   slices = file.getSize();
   for (int i = 1; i <= file.getSize(); i++) {
     for (int y = 0; y < file.getHeight(); y++) {
       final float[] point = new float[14];
       for (int x = 0; x < file.getWidth(); x++) {
         point[x] = file.getProcessor(i).getf(x, y);
       }
       this.add(point);
     }
   }
 }
Пример #9
0
  /**
   * Main method for debugging.
   *
   * <p>For debugging, it is convenient to have a method that starts ImageJ, loads an image and
   * calls the plugin, e.g. after setting breakpoints.
   *
   * @param args unused
   */
  public static void main(String[] args) {
    // set the plugins.dir property to make the plugin appear in the Plugins menu
    Class<?> clazz = Panorama_View.class;
    String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
    String pluginsDir = url.substring(5, url.length() - clazz.getName().length() - 6);
    System.setProperty("plugins.dir", pluginsDir);

    // start ImageJ
    new ImageJ();

    // open the Clown sample
    ImagePlus image =
        IJ.openImage(
            "http://fly.mpi-cbg.de/~saalfeld/Projects/download/panorama/theaterplatz_3400.jpg");
    image.show();

    // run the plugin
    IJ.runPlugIn(clazz.getName(), "");
  }
Пример #10
0
 public int[] extractBytes(String ImageName) {
   // open image
   int n = 0;
   int chardata[] = new int[35];
   ImagePlus I3 = IJ.openImage(ImageName);
   ImageProcessor ip1 = I3.getProcessor();
   for (int j = 0; j < 7; j++) {
     for (int k = 0; k < 5; k++) {
       int temp = ip1.getPixel(k, j);
       if (temp == 255) {
         chardata[n] = 1;
       } else {
         chardata[n] = 0;
       }
       // System.out.println("getpixel  = "+temp);
       n++;
     }
   }
   return chardata;
 }
  @Test
  public final void testErosionCochleaVolumeC26() {
    String fileName = getClass().getResource("/files/bat-cochlea-volume.tif").getFile();
    ImagePlus imagePlus = IJ.openImage(fileName);

    assertNotNull(imagePlus);
    assertTrue(imagePlus.getStackSize() > 0);

    ImageStack mask = imagePlus.getStack();
    // Ensure regularity of the mask
    mask = Morphology.opening(mask, CubeStrel.fromRadius(1));
    invertGray8Stack(mask);

    int width = mask.getWidth();
    int height = mask.getHeight();
    int depth = mask.getSize();
    int bitDepth = mask.getBitDepth();
    ImageStack marker = ImageStack.create(width, height, depth, bitDepth);
    marker.setVoxel(20, 80, 50, 255);
    invertGray8Stack(marker);

    GeodesicReconstruction3DHybrid0Gray8 algo =
        new GeodesicReconstruction3DHybrid0Gray8(GeodesicReconstructionType.BY_EROSION);
    algo.setConnectivity(26);

    ImageStack result = algo.applyTo(marker, mask);

    for (int z = 0; z < depth; z++) {
      for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
          if (Math.abs(result.getVoxel(x, y, z) - mask.getVoxel(x, y, z)) > .1) {
            System.out.println("x=" + x + " y=" + y + " z=" + z);
            System.out.println("  mask = " + (int) mask.getVoxel(x, y, z));
            System.out.println("  res  = " + (int) result.getVoxel(x, y, z));
            assertTrue(false);
          }
        }
      }
    }
  }
Пример #12
0
  @Test
  public final void testRegionalMaxima_BatCochlea() {
    String fileName = getClass().getResource("/files/bat-cochlea-volume.tif").getFile();
    ImagePlus imagePlus = IJ.openImage(fileName);
    assertNotNull(imagePlus);
    assertTrue(imagePlus.getStackSize() > 0);

    // load the reference image, and get its size
    ImageStack image = imagePlus.getStack();
    int sizeX = image.getWidth();
    int sizeY = image.getHeight();
    int sizeZ = image.getSize();

    // create test image:
    // use cochlea volume, but add a band with value 127 in the middle
    int zMid = sizeZ / 2;
    for (int y = 0; y < sizeY; y++) {
      for (int x = 0; x < sizeX; x++) {
        double val = image.getVoxel(x, y, zMid);
        if (val == 255) image.setVoxel(x, y, zMid, 127);
      }
    }

    ImageStack maxima = MinimaAndMaxima3D.regionalMaxima(image);

    for (int z = 0; z < sizeZ; z++) {
      for (int y = 0; y < sizeY; y++) {
        for (int x = 0; x < sizeX; x++) {
          int v0 = (int) image.getVoxel(x, y, z);
          int v = (int) maxima.getVoxel(x, y, z);
          if (v0 == 255) assertEquals(255, v);
          else assertEquals(0, v);
        }
      }
    }
  }
Пример #13
0
 public void set(String name) {
   Im = IJ.openImage(name);
   run("");
 }
Пример #14
0
  /**
   * This main method is used for testing. It starts ImageJ, loads a test image and starts the
   * plugin.
   *
   * <p>User interaction is necessary, as the plugin uses a GUI.
   *
   * <p><a href=
   * "https://github.com/imagej/minimal-ij1-plugin/blob/master/src/main/java/Process_Pixels.java"
   * >see minimal-ij1-plugin on GitHub</a>
   *
   * @param args
   */
  public static void main(final String[] args) {
    EFTEMj_Debug.setDebugLevel(EFTEMj_Debug.DEBUG_FULL);
    /*
     * start ImageJ
     */
    new ImageJ();

    String baseFolder = "C:/Temp/";
    final String os = System.getProperty("os.name").toLowerCase();
    if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0 || os.indexOf("aix") > 0) {
      final String userHome = System.getProperty("user.home");
      baseFolder = userHome + "/Downloads/";
    }

    /*
     * Check if the test image is available. Otherwise prompt a message with
     * the download link.
     */
    final File testImage =
        new File(baseFolder + "20140106 SM125 -20%/20140106_SR-EELS_TestImage_small.tif");
    if (!testImage.exists()) {
      final String url = "http://eftemj.entrup.com.de/SR-EELS_TestImage.zip";
      /*
       * IJ.showMessage("Test image not found", "<html>" +
       * "Please download the file" + "<br />" + "<a href='" + url +
       * "'>SR-EELS_TestImage.zip</a> from" + "<br/>" + url + "<br />" +
       * "and extract it to 'C:\\temp\\'." + "</html>");
       */
      final GenericDialog gd = new GenericDialog("Test image not found");
      gd.addMessage(
          "Please download the file 'SR-EELS_TestImage.zip' and extract it to '"
              + baseFolder
              + "'.");
      gd.addMessage("Copy the following link, or click Ok to open it with your default browser.");
      gd.addStringField("", url, url.length());
      gd.showDialog();
      if (gd.wasOKed()) {
        try {
          final URI link = new URI(url);
          final Desktop desktop = Desktop.getDesktop();
          desktop.browse(link);
        } catch (final Exception exc) {
          IJ.showMessage("An Exception occured", exc.getMessage());
          return;
        }
      }
      return;
    }
    /*
     * open the test image
     */
    final ImagePlus image =
        IJ.openImage(baseFolder + "20140106 SM125 -20%/20140106_SR-EELS_TestImage_small.tif");
    image.show();

    /*
     * run the plugin
     */
    final Class<?> clazz = SR_EELS_CorrectionPlugin.class;
    IJ.runPlugIn(clazz.getName(), "");
  }