Package ij.measure

Examples of ij.measure.Calibration


    IJ.error("FileSaver", "An error occured writing the file.\n \n" + msg);
  }

  /** Returns a string containing information about the specified  image. */
  public String getDescriptionString() {
    Calibration cal = imp.getCalibration();
    StringBuffer sb = new StringBuffer(100);
    sb.append("ImageJ="+ImageJ.VERSION+"\n");
    if (fi.nImages>1 && fi.fileType!=FileInfo.RGB48)
      sb.append("images="+fi.nImages+"\n");
    int channels = imp.getNChannels();
    if (channels>1)
      sb.append("channels="+channels+"\n");
    int slices = imp.getNSlices();
    if (slices>1)
      sb.append("slices="+slices+"\n");
    int frames = imp.getNFrames();
    if (frames>1)
      sb.append("frames="+frames+"\n");
    if (imp.isHyperStack()) sb.append("hyperstack=true\n");
    if (imp.isComposite()) {
      int mode = ((CompositeImage)imp).getMode();
      String s = null;
      switch (mode) {
        case CompositeImage.COMPOSITE: s="composite"; break;
        case CompositeImage.COLOR: s="color"; break;
        case CompositeImage.GRAYSCALE: s="gray"; break;
      }
      sb.append("mode="+s+"\n");
    }
    if (fi.unit!=null)
      sb.append("unit="+fi.unit+"\n");
    if (fi.valueUnit!=null && fi.calibrationFunction!=Calibration.CUSTOM) {
      sb.append("cf="+fi.calibrationFunction+"\n");
      if (fi.coefficients!=null) {
        for (int i=0; i<fi.coefficients.length; i++)
          sb.append("c"+i+"="+fi.coefficients[i]+"\n");
      }
      sb.append("vunit="+fi.valueUnit+"\n");
      if (cal.zeroClip()) sb.append("zeroclip=true\n");
    }
   
    // get stack z-spacing and fps
    if (fi.nImages>1) {
      if (fi.pixelDepth!=0.0 && fi.pixelDepth!=1.0)
        sb.append("spacing="+fi.pixelDepth+"\n");
      if (cal.fps!=0.0) {
        if ((int)cal.fps==cal.fps)
          sb.append("fps="+(int)cal.fps+"\n");
        else
          sb.append("fps="+cal.fps+"\n");
      }
      sb.append("loop="+(cal.loop?"true":"false")+"\n");
      if (cal.frameInterval!=0.0) {
        if ((int)cal.frameInterval==cal.frameInterval)
          sb.append("finterval="+(int)cal.frameInterval+"\n");
        else
          sb.append("finterval="+cal.frameInterval+"\n");
      }
      if (!cal.getTimeUnit().equals("sec"))
        sb.append("tunit="+cal.getTimeUnit()+"\n");
    }
   
    // get min and max display values
    ImageProcessor ip = imp.getProcessor();
    double min = ip.getMin();
View Full Code Here


    if (IJ.debugMode) IJ.log("FolderOpener: "+directory+" ("+list.length+" files)");
    int width=0,height=0,depth=0,bitDepth=0;
    ImageStack stack = null;
    double min = Double.MAX_VALUE;
    double max = -Double.MAX_VALUE;
    Calibration cal = null;
    boolean allSameCalibration = true;
    IJ.resetEscape();   
    try {
      for (int i=0; i<list.length; i++) {
        IJ.redirectErrorMessages();
View Full Code Here

  /** Sets the minimum and maximum displayed pixel values. */
  public static void setMinAndMax(double min, double max) {
    ImagePlus img = getImage();
    if (img.getBitDepth()==16) {
      Calibration cal = img.getCalibration();
      min = cal.getRawValue(min);
      max = cal.getRawValue(max);
    }
    img.getProcessor().setMinAndMax(min, max);
    img.updateAndDraw();
  }
View Full Code Here

      else if (displayMode.indexOf("no")!=-1)
        mode = ImageProcessor.NO_LUT_UPDATE;
    }
    ImagePlus img = getImage();
    if (img.getBitDepth()==16) {
      Calibration cal = img.getCalibration();
      lowerThreshold = cal.getRawValue(lowerThreshold);
      upperThreshold = cal.getRawValue(upperThreshold);
    }
    img.getProcessor().setThreshold(lowerThreshold, upperThreshold, mode);
    if (mode != ImageProcessor.NO_LUT_UPDATE) {
      img.getProcessor().setLutAnimation(true);
      img.updateAndDraw();
View Full Code Here

      //if (fi.fileType==FileInfo.GRAY16_SIGNED && imp.getStackSize()==1)
      //  convertToUnsigned(imp, fi);
      if (dd.windowWidth>0.0) {
        double min = dd.windowCenter-dd.windowWidth/2;
        double max = dd.windowCenter+dd.windowWidth/2;
        Calibration cal = imp.getCalibration();
        if (cal.getCValue(0)!=0) {
          min -= cal.getCValue(0);
          max -= cal.getCValue(0);
        }
        ip.setMinAndMax(min, max);
        if (IJ.debugMode) IJ.log("window: "+min+"-"+max);
      }
      if (imp.getStackSize()>1)
View Full Code Here

    if (IJ.debugMode) IJ.log("min: "+(min-32768));
    if (min>=32768) {
      for (int i=0; i<pixels.length; i++)
        pixels[i] = (short)(pixels[i]-32768);
      ip.resetMinAndMax();
      Calibration cal = imp.getCalibration();
      cal.setFunction(Calibration.NONE, null, "Gray Value");
      fi.fileType = FileInfo.GRAY16_UNSIGNED;
    }
  }
View Full Code Here

    if (win!=null)
      WindowManager.setCurrentWindow(win);
    Undo.reset();
    ImageStack stack1 = img1.getStack();
    StackProcessor sp = new StackProcessor(stack1, img1.getProcessor());
    Calibration cal2 = img2.getCalibration();
    img2.getProcessor().setCalibrationTable(cal2.getCTable());
    try {
      if (size2==1)
        sp.copyBits(img2.getProcessor(), 0, 0, mode);
      else
        sp.copyBits(img2.getStack(), 0, 0, mode);
View Full Code Here

  void doOperation(ImagePlus img1, ImagePlus img2) {
    int mode = getBlitterMode();
    ImageProcessor ip1 = img1.getProcessor();
    ImageProcessor ip2 = img2.getProcessor();
    Calibration cal1 = img1.getCalibration();
    Calibration cal2 = img2.getCalibration();
    if (createWindow)
      ip1 = createNewImage(ip1, ip2, cal1);
    else {
      ImageWindow win = img1.getWindow();
      if (win!=null)
        WindowManager.setCurrentWindow(win);
      ip1.snapshot();
      Undo.setup(Undo.FILTER, img1);
    }
    if (floatResult) {
      ip2.setCalibrationTable(cal2.getCTable());
      ip2 = ip2.convertToFloat();
    }
    try {
      ip1.copyBits(ip2, 0, 0, mode);
    }
View Full Code Here

    }
    return mode;
  }
 
  ImagePlus duplicateStack(ImagePlus img1) {
    Calibration cal = img1.getCalibration();
    ImageStack stack1 = img1.getStack();
    int width = stack1.getWidth();
    int height = stack1.getHeight();
    int n = stack1.getSize();
    ImageStack stack2 = img1.createEmptyStack();
    try {
      for (int i=1; i<=n; i++) {
        ImageProcessor ip1 = stack1.getProcessor(i);
        ip1.resetRoi();
        ImageProcessor ip2 = ip1.crop();
        if (floatResult) {
          ip2.setCalibrationTable(cal.getCTable());
          ip2 = ip2.convertToFloat();
        }
        stack2.addSlice(stack1.getSliceLabel(i), ip2);
      }
    }
View Full Code Here

    }
    if (stack!=null) {
      imp = new ImagePlus("Imported Stack", stack);
      if (imp.getBitDepth()==16 || imp.getBitDepth()==32)
        imp.getProcessor().setMinAndMax(min, max);
                Calibration cal = imp.getCalibration();
                if (fi.fileType==FileInfo.GRAY16_SIGNED) {
                    double[] coeff = new double[2];
                    coeff[0] = -32768.0;
                    coeff[1] = 1.0;
                    cal.setFunction(Calibration.STRAIGHT_LINE, coeff, "gray value");
                }
      imp.show();
    }
  }
View Full Code Here

TOP

Related Classes of ij.measure.Calibration

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.