Package ij

Examples of ij.ImagePlus


    ArrayList imps = new ArrayList();
    IJ.showProgress(1.0);
   
    for (int stackCount = 0; stackCount < (int) stacks.length; stackCount++) {
      if (stacks[stackCount].getSize() > 0) {
        ImagePlus imp = new ImagePlus(lsmFi.fileName,
            stacks[stackCount]);
        imp.setFileInfo(lsmFi);

        Calibration cal = new Calibration();
        cal.setUnit(lsmFi.unit);
        cal.pixelDepth = lsmFi.pixelDepth;
        cal.pixelHeight = lsmFi.pixelHeight;
        cal.pixelWidth = lsmFi.pixelWidth;
        imp.setCalibration(cal);
        imp.setTitle(lsmFi.fileName + " Channel : "
            + cz.channelNamesAndColors.ChannelNames[stackCount]);
        Color[] color = new Color[2];
        color[0] = new Color(0, 0, 0);
        int r = (int) (cz.channelNamesAndColors.Colors[stackCount] & 255);
        int g = (int) ((cz.channelNamesAndColors.Colors[stackCount] >> 8) & 255);
        int b = (int) ((cz.channelNamesAndColors.Colors[stackCount] >> 16) & 255);
        color[1] = new Color(r, g, b);
        if (r == 0 && g == 0 && b == 0)
          color[1] = Color.white;
        ReaderToolkit.apply_colors(imp, color, 2);

        if (imp.getOriginalFileInfo().fileType == FileInfo.GRAY16_UNSIGNED) {
          double min = imp.getProcessor().getMin();
          double max = imp.getProcessor().getMax();
          imp.getProcessor().setMinAndMax(min, max);
        }

        imps.add(imp);
      }
    }
View Full Code Here


    }
    ArrayList imps = new ArrayList();
    IJ.showProgress(1.0);
    for (int stackCount = 0; stackCount < (int) stacks.length; stackCount++) {
      if (stacks[stackCount].getSize() > 0) {
        ImagePlus imp = new ImagePlus(lsmFi.fileName,
            stacks[stackCount]);
        imp.setFileInfo(lsmFi);

        Calibration cal = new Calibration();
        cal.setUnit(lsmFi.unit);
        cal.pixelDepth = lsmFi.pixelDepth;
        cal.pixelHeight = lsmFi.pixelHeight;
        cal.pixelWidth = lsmFi.pixelWidth;
        imp.setCalibration(cal);
        imp.setTitle(lsmFi.fileName + " Channel : "
            + cz.channelNamesAndColors.ChannelNames[stackCount]);
        Color[] color = new Color[2];
        color[0] = new Color(0, 0, 0);
        int r = (int) (cz.channelNamesAndColors.Colors[stackCount] & 255);
        int g = (int) ((cz.channelNamesAndColors.Colors[stackCount] >> 8) & 255);
        int b = (int) ((cz.channelNamesAndColors.Colors[stackCount] >> 16) & 255);
        color[1] = new Color(r, g, b);
        if (r == 0 && g == 0 && b == 0)
          color[1] = Color.white;
        apply_colors(imp, color, 2);

        if (imp.getOriginalFileInfo().fileType == FileInfo.GRAY16_UNSIGNED) {
          double min = imp.getProcessor().getMin();
          double max = imp.getProcessor().getMax();
          imp.getProcessor().setMinAndMax(min, max);
        }

        imps.add(imp);
      }
    }
View Full Code Here

            } finally {
                IOUtils.closeQuietly(os);
                IOUtils.closeQuietly(is);
            }
            Opener op = new Opener();
            ImagePlus ip = op.openImage(tmp.getPath());
            return new ImageJImage(node.getPath(), ip, op.getFileType(tmp.getPath()));
        } finally {
            IOUtils.closeQuietly(os);
            FileUtils.deleteQuietly(tmp);
        }
View Full Code Here

    /**
     * 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);
    }
View Full Code Here

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

    public int getHeight(Image i) {
        ImagePlus ip = ((ImageJImage)i).getImagePlus();
        if (ip != null) {
            return ip.getHeight();
        }
        return -1;
    }
View Full Code Here

        }
        return -1;
    }

    public int getWidth(Image i) {
        ImagePlus ip = ((ImageJImage)i).getImagePlus();
        if (ip != null) {
            return ip.getWidth();
        }
        return -1;
    }
View Full Code Here

        }
        return -1;
    }

    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);
    }
View Full Code Here

        return ImageProcess.save(((ImageJImage) i).getImageType(), ip, outputFile);
    }

    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);
    }
View Full Code Here

        return ImageProcess.save(((ImageJImage) i).getImageType(), ip, outputFile);
    }

    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);
    }
View Full Code Here

            IOUtils.copy(istream, out);
        } finally {
            IOUtils.closeQuietly(out);
        }
        Opener op = new Opener();
        ImagePlus ip = op.openImage(tmp.getPath());
        if (ip == null ) {
            return false;
        }
        int type = op.getFileType(tmp.getPath());
        tmp.delete();
        ImageProcessor processor = ip.getProcessor();
        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);

        return save(type,ip,outputFile);
    }
View Full Code Here

TOP

Related Classes of ij.ImagePlus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.