Package ij.process

Examples of ij.process.ImageProcessor


        }
        if (debug)
            movie.addSlice("Filtered EDM", ip.duplicate());
        makeCoordinateArrays(ip);
        byte[] image = (byte[]) ip.getPixels();
        ImageProcessor ip2 = null;
        if (watershed)
            ip2 = ip.duplicate();
        int width = ip.getWidth();
        int height = ip.getHeight();
        rowsize = width;
        xmax = width - 1;
        ymax = height - 1;
        for (int level = maxEDM - 1; level >= 1; level--) {
            do {
                count = 0;
                for (int i = 0; i < histogram[level]; i++) {
                    CoordOffset = levelStart[level] + i;
                    x = xCoordinate[CoordOffset];
                    y = yCoordinate[CoordOffset];
                    offset = x + y * rowsize;
                    if ((image[offset] & 255) != 255) {
                        setPixel = false;
                        if ((x > 0)
                                && (y > 0)
                                && ((image[offset - rowsize - 1] & 255) > level))
                            setPixel = true;
                        if ((y > 0)
                                && ((image[offset - rowsize] & 255) > level))
                            setPixel = true;
                        if ((x < xmax)
                                && (y > 0)
                                && ((image[offset - rowsize + 1] & 255) > level))
                            setPixel = true;
                        if ((x < xmax) && ((image[offset + 1] & 255) > level))
                            setPixel = true;
                        if ((x < xmax)
                                && (y < ymax)
                                && ((image[offset + rowsize + 1] & 255) > level))
                            setPixel = true;
                        if ((y < ymax)
                                && ((image[offset + rowsize] & 255) > level))
                            setPixel = true;
                        if ((x > 0)
                                && (y < ymax)
                                && ((image[offset + rowsize - 1] & 255) > level))
                            setPixel = true;
                        if ((x > 0) && ((image[offset - 1] & 255) > level))
                            setPixel = true;
                        if (setPixel) {
                            image[offset] = (byte) 255;
                            count++;
                        }
                    } // if pixel not 255 */
                } // for i
            } while (count != 0);
        } // for

        if (watershed) {
            byte[] image2 = (byte[]) ip2.getPixels();
            for (int i = 0; i < width * height; i++) {
                if (((image[i] & 255) > 0) && ((image[i] & 255) < 255))
                    image2[i] = (byte) 0xff;
            }
            ip.insert(ip2, 0, 0);
View Full Code Here


    private void filterEDM(ImageProcessor edm, boolean smooth) {
        int rowsize, offset;
        int xmax, ymax;

        byte[] image = (byte[]) edm.getPixels();
        ImageProcessor ip2 = edm.duplicate();
        byte[] image2 = (byte[]) ip2.getPixels();
        int width = edm.getWidth();
        int height = edm.getHeight();
        rowsize = width;
        xmax = width - 1;
        ymax = height - 1;
View Full Code Here

    private void doWatershed(ImageProcessor ip1) {
        int[] table = makeFateTable();
        if (debug)
            movie.addSlice("EDM+UEPs", ip1.duplicate());
        IJ.showStatus("Watershed (press esc to cancel)");
        ImageProcessor ip2 = ip1.duplicate();
        for (int level = maxEDM - 1; level >= 1; level--) {
            IJ.showProgress(maxEDM - level, maxEDM - 1);
            do {
                count = 0;
                processLevel(level, 1, ip1, ip2, table);
View Full Code Here

  /***************************************************************************
   * method : saveAs8bitTiff, image processing for 8-bit Tiff saving *
   **************************************************************************/

  void saveAs8bitTiff(ImagePlus img, String path) {
    ImageProcessor ip = img.getProcessor();
    if (ip instanceof ColorProcessor) {
      ip = reduceColors(ip);
      img.setProcessor(null, ip);
    } else if ((ip instanceof ShortProcessor)
        || (ip instanceof FloatProcessor)) {
      ip = ip.convertToByte(true);
      img.setProcessor(null, ip);
    }
    new FileSaver(img).saveAsTiff(path);
  }
View Full Code Here

    int x = 2;
    int y = 40;
    double ps = 0;
    ImageStack stack = imp.getStack();
    Font font = new Font("SansSerif", Font.PLAIN, 20);
    ImageProcessor ip = imp.getProcessor();
    Rectangle roi = ip.getRoi();
    if (roi.width < ip.getWidth() || roi.height < ip.getHeight()) {
      x = roi.x;
      y = roi.y + roi.height;
    }
    Color c = Toolbar.getForegroundColor();
    CZ_LSMInfo cz = (CZ_LSMInfo) ((ImageDirectory) lfi.imageDirectories
        .get(0)).TIF_CZ_LSMINFO;
    if (cz.DimensionZ != 1) {
      Recording r = (Recording) cz.scanInfo.recordings
          .get(0);
      double planeSpacing = ((Double) r.records.get("PLANE SPACING"))
          .doubleValue();

      if ((cz.DimensionTime == 1)) {

        for (int slice = 1; slice <= cz.DimensionZ; slice++) {
          IJ.showStatus("MinMax: " + slice + "/"
              + cz.DimensionZ);
          String s = IJ.d2s(ps, 2) + " "+MasterModel.micrometer;
          ps += planeSpacing;
          ip = stack.getProcessor(slice);
          ip.setFont(font);
          float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c
              .getBlue(), null);
          ip.setColor(Color.getHSBColor(255, 255, 255 - hsb[2]));
          ip.moveTo(x, y);
          ip.drawString(s);
        }
      } else if (cz.DimensionTime != 1) {
        for (int slicez = 1; slicez <= cz.DimensionZ; slicez++) {
          IJ.showStatus("MinMax: " + slicez + "/"
              + cz.DimensionZ);
          String s = IJ.d2s(ps, 2) + " " + MasterModel.micrometer;
          ps += planeSpacing;
          for (int slicet = 1; slicet <= cz.DimensionTime; slicet++) {
            ip = stack
                .getProcessor((int) cz.DimensionZ
                    * (slicet - 1) + slicez);
            ip.setFont(font);
            float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(),
                c.getBlue(), null);
            ip.setColor(Color.getHSBColor(255, 255, 255 - hsb[2]));
            ip.moveTo(x, y);
            ip.drawString(s);
          }
        }
      }
    }
    imp.updateAndRepaintWindow();
View Full Code Here

    int x = 2;
    int y = 20;

    ImageStack stack = imp.getStack();
    Font font = new Font("SansSerif", Font.PLAIN, 20);
    ImageProcessor ip = imp.getProcessor();
    Rectangle roi = ip.getRoi();
    if (roi.width < ip.getWidth() || roi.height < ip.getHeight()) {
      x = roi.x;
      y = roi.y + roi.height;
    }
    Color c = Toolbar.getForegroundColor();
    CZ_LSMInfo cz = (CZ_LSMInfo) ((ImageDirectory) lfi.imageDirectories
        .get(0)).TIF_CZ_LSMINFO;
    if ((cz.DimensionTime == 1)
        ^ (cz.DimensionZ == 1)) {
      //int size = imp.getStackSize();
      for (int slice = 1; slice <= cz.timeStamps.NumberTimeStamps; slice++) {
        IJ.showStatus("MinMax: " + slice + "/"
            + cz.timeStamps.NumberTimeStamps);
        String s = IJ
            .d2s(
                cz.timeStamps.TimeStamps[slice - 1],
                2)
            + " s";
        ip = stack.getProcessor(slice);
        ip.setFont(font);
        float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c
            .getBlue(), null);
        ip.setColor(Color.getHSBColor(255, 255, 255 - hsb[2]));
        ip.moveTo(x, y);
        ip.drawString(s);
      }

    } else if ((cz.DimensionTime != 1)
        && (cz.DimensionZ != 1)) {
      for (int slicet = 1; slicet <= cz.DimensionTime; slicet++) {
        IJ.showStatus("MinMax: " + slicet + "/"
            + cz.DimensionTime);
        String s = IJ.d2s(
            cz.timeStamps.TimeStamps[slicet - 1],
            2)
            + " s";
        for (int slicez = 1; slicez <= cz.DimensionZ; slicez++) {
          ip = stack
              .getProcessor((int) cz.DimensionZ
                  * (slicet - 1) + slicez);
          ip.setFont(font);
          float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c
              .getBlue(), null);
          ip.setColor(Color.getHSBColor(255, 255, 255 - hsb[2]));
          ip.moveTo(x, y);
          ip.drawString(s);

        }
      }
    }
    imp.updateAndRepaintWindow();
View Full Code Here

  public void applyLSTAMP(ImagePlus imp, LsmFileInfo lfi,
      double channelWaveLength) {
    int x = 2;
    int y = 60;
    ImageProcessor ip = imp.getProcessor();
    Rectangle roi = ip.getRoi();
    if (roi.width < ip.getWidth() || roi.height < ip.getHeight()) {
      x = roi.x;
      y = roi.y + roi.height;
    }
    ImageStack stack = imp.getStack();
    Font font = new Font("SansSerif", Font.PLAIN, 20);
    Color c = Toolbar.getForegroundColor();

    for (int slice = 1; slice <= stack.getSize(); slice++) {
      String s = IJ.d2s(channelWaveLength * 1000000000, 2) + " nm";
      ip = stack.getProcessor(slice);
      ip.setFont(font);
      float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(),
          null);
      ip.setColor(Color.getHSBColor(255, 255, 255 - hsb[2]));
      ip.moveTo(x, y);
      ip.drawString(s);
    }
    imp.updateAndRepaintWindow();
  }
View Full Code Here

    static void showLut(ImagePlus imp, FileInfo fi, boolean showImage) {
        if (imp != null) {
            if (imp.getType() == ImagePlus.COLOR_RGB)
                IJ.error("Color tables cannot be assiged to RGB Images.");
            else {
                ImageProcessor ip = imp.getProcessor();
                ColorModel cm = new IndexColorModel(8, 256, fi.reds, fi.greens,
                        fi.blues);
                ip.setColorModel(cm);
                if (imp.getStackSize() > 1)
                    imp.getStack().setColorModel(cm);
                imp.updateAndDraw();
            }
        }
View Full Code Here

                        img = process(img);
                        if (img!=null){
                            if (img.getStackSize() != 1) {
                                for (int slice=0; slice<img.getStackSize(); slice++){
                                    img.setSlice(slice);
                                    ImageProcessor ip = img.getProcessor();
                                    ImageProcessor newip = ip.createProcessor(ip.getWidth(),ip.getHeight());
                                    newip.setPixels(ip.getPixelsCopy());
                                    String slicename = img.getTitle();
                                    slicename +=("_slice");
                                    String numb = IJ.d2s(slice,0);
                                    slicename += "_"+numb;
                                    ImagePlus img2 = new ImagePlus(slicename, newip);
View Full Code Here

    /*******************************************************************
     * method : saveAs8bitTiff, image processing for 8-bit Tiff saving *
     ******************************************************************/
   
    void saveAs8bitTiff(ImagePlus img, String path) {
        ImageProcessor ip = img.getProcessor();
        if (ip instanceof ColorProcessor) {
            ip = reduceColors(ip); img.setProcessor(null, ip);} else if ((ip instanceof ShortProcessor) || (ip instanceof FloatProcessor)) {
            ip = ip.convertToByte(true); img.setProcessor(null, ip);}
        new FileSaver(img).saveAsTiff(path);
    }
View Full Code Here

TOP

Related Classes of ij.process.ImageProcessor

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.