Ejemplo n.º 1
0
  public boolean resizeImage(Image i, File outputFile, int width, int height) {
    ImagePlus ip = ((ImageJImage) i).getImagePlus();
    ImageProcessor processor = ip.getProcessor();
    processor = processor.resize(width, height);
    ip.setProcessor(null, processor);

    return ImageProcess.save(((ImageJImage) i).getImageType(), ip, outputFile);
  }
Ejemplo n.º 2
0
  public boolean cropImage(Image i, File outputFile, int top, int left, int width, int height) {
    ImagePlus ip = ((ImageJImage) i).getImagePlus();
    ImageProcessor processor = ip.getProcessor();

    processor.setRoi(left, top, width, height);
    processor = processor.crop();
    ip.setProcessor(null, processor);

    return ImageProcess.save(((ImageJImage) i).getImageType(), ip, outputFile);
  }
Ejemplo n.º 3
0
  public boolean rotateImage(Image i, File outputFile, boolean clockwise) {
    ImagePlus ip = ((ImageJImage) i).getImagePlus();
    ImageProcessor processor = ip.getProcessor();
    if (clockwise) {
      processor = processor.rotateRight();
    } else {
      processor = processor.rotateLeft();
    }
    ip.setProcessor(null, processor);

    return ImageProcess.save(((ImageJImage) i).getImageType(), ip, outputFile);
  }
Ejemplo n.º 4
0
  /**
   * Creates a JPEG thumbnail from inputFile and saves it to disk in outputFile. scaleWidth is the
   * width to scale the image to
   */
  public boolean createThumb(Image iw, File outputFile, int size, boolean square)
      throws IOException {
    ImagePlus ip = ((ImageJImage) iw).getImagePlus();
    // Load the input image.
    if (ip == null) {
      return false;
    }
    ip = new ImagePlus(ip.getTitle(), ip.getImageStack());
    ImageProcessor processor = ip.getProcessor();
    if (square) {
      processor = processor.resize(size, size);
    } else if (ip.getWidth() > ip.getHeight()) {
      processor = processor.resize(size, ip.getHeight() * size / ip.getWidth());
    } else {
      processor = processor.resize(ip.getWidth() * size / ip.getHeight(), size);
    }
    ip.setProcessor(null, processor);
    int type = ((ImageJImage) iw).getImageType();

    return ImageProcess.save(type, ip, outputFile);
  }