FloatProcessor downsize(int dstWidth, int dstHeight, String msg) { FloatProcessor ip2 = this; if (msg!=null) ij.IJ.showStatus("downsizing in x"+msg); if (dstWidth<roiWidth) { //downsizing in x ip2 = ip2.downsize1D(dstWidth, roiHeight, true); ip2.setRoi(0, 0, dstWidth, roiHeight); //prepare roi for resizing in y } if (msg!=null) ij.IJ.showStatus("downsizing in y"+msg); if (dstHeight<roiHeight) //downsizing in y ip2 = ip2.downsize1D(ip2.getRoi().width, dstHeight, false); if (ip2.getWidth()!=dstWidth || ip2.getHeight()!=dstHeight) ip2 = (FloatProcessor)ip2.resize(dstWidth, dstHeight); //do any upsizing if required return ip2; }
/** Returns a FloatProcessor with one color channel of the image. * The roi and mask are also set for the FloatProcessor. * @param channelNumber Determines the color channel, 0=red, 1=green, 2=blue * @param fp Here a FloatProcessor can be supplied, or null. The FloatProcessor * is overwritten by this method (re-using its pixels array * improves performance). * @return A FloatProcessor with the converted image data of the color channel selected */ public FloatProcessor toFloat(int channelNumber, FloatProcessor fp) { int size = width*height; if (fp == null || fp.getWidth()!=width || fp.getHeight()!=height) fp = new FloatProcessor(width, height, new float[size], null); float[] fPixels = (float[])fp.getPixels(); int shift = 16 - 8*channelNumber; int byteMask = 255<<shift; for (int i=0; i<size; i++) fPixels[i] = (pixels[i]&byteMask)>>shift; fp.setRoi(getRoi()); fp.setMask(mask); fp.setMinAndMax(0, 255); return fp; }
/** Returns a FloatProcessor with one color channel of the image. * The roi and mask are also set for the FloatProcessor. * @param channelNumber Determines the color channel, 0=red, 1=green, 2=blue * @param fp Here a FloatProcessor can be supplied, or null. The FloatProcessor * is overwritten by this method (re-using its pixels array * improves performance). * @return A FloatProcessor with the converted image data of the color channel selected */ public FloatProcessor toFloat(int channelNumber, FloatProcessor fp) { int size = width*height; if (fp == null || fp.getWidth()!=width || fp.getHeight()!=height) fp = new FloatProcessor(width, height, new float[size], null); float[] fPixels = (float[])fp.getPixels(); int shift = 16 - 8*channelNumber; int byteMask = 255<<shift; for (int i=0; i<size; i++) fPixels[i] = (pixels[i]&byteMask)>>shift; fp.setRoi(getRoi()); fp.setMask(mask); fp.setMinAndMax(0, 255); return fp; }
FloatProcessor downsize(int dstWidth, int dstHeight, String msg) { FloatProcessor ip2 = this; if (msg!=null) ij.IJ.showStatus("downsizing in x"+msg); if (dstWidth<roiWidth) { //downsizing in x ip2 = ip2.downsize1D(dstWidth, roiHeight, true); ip2.setRoi(0, 0, dstWidth, roiHeight); //prepare roi for resizing in y } if (msg!=null) ij.IJ.showStatus("downsizing in y"+msg); if (dstHeight<roiHeight) //downsizing in y ip2 = ip2.downsize1D(ip2.getRoi().width, dstHeight, false); if (ip2.getWidth()!=dstWidth || ip2.getHeight()!=dstHeight) ip2 = (FloatProcessor)ip2.resize(dstWidth, dstHeight); //do any upsizing if required return ip2; }
/** Returns a FloatProcessor with the same image, no scaling or calibration * (pixel values 0 to 255). * The roi, mask, lut (ColorModel), threshold, min&max are * also set for the FloatProcessor * @param channelNumber Ignored (needed for compatibility with ColorProcessor.toFloat) * @param fp Here a FloatProcessor can be supplied, or null. The FloatProcessor * is overwritten by this method (re-using its pixels array * improves performance). * @return A FloatProcessor with the converted image data */ public FloatProcessor toFloat(int channelNumber, FloatProcessor fp) { int size = width*height; if (fp == null || fp.getWidth()!=width || fp.getHeight()!=height) fp = new FloatProcessor(width, height, new float[size], cm); float[] fPixels = (float[])fp.getPixels(); for (int i=0; i<size; i++) fPixels[i] = pixels[i]&0xff; fp.setRoi(getRoi()); fp.setMask(mask); fp.setMinAndMax(min, max); fp.setThreshold(minThreshold, maxThreshold, ImageProcessor.NO_LUT_UPDATE); return fp; }
/** Returns a FloatProcessor with the same image, no scaling or calibration * (pixel values 0 to 255). * The roi, mask, lut (ColorModel), threshold, min&max are * also set for the FloatProcessor * @param channelNumber Ignored (needed for compatibility with ColorProcessor.toFloat) * @param fp Here a FloatProcessor can be supplied, or null. The FloatProcessor * is overwritten by this method (re-using its pixels array * improves performance). * @return A FloatProcessor with the converted image data */ public FloatProcessor toFloat(int channelNumber, FloatProcessor fp) { int size = width*height; if (fp == null || fp.getWidth()!=width || fp.getHeight()!=height) fp = new FloatProcessor(width, height, new float[size], cm); float[] fPixels = (float[])fp.getPixels(); for (int i=0; i<size; i++) fPixels[i] = pixels[i]&0xff; fp.setRoi(getRoi()); fp.setMask(mask); fp.setMinAndMax(min, max); fp.setThreshold(minThreshold, maxThreshold, ImageProcessor.NO_LUT_UPDATE); return fp; }
/** Returns a FloatProcessor with the same image, no scaling or calibration * (pixel values 0 to 65535). * The roi, mask, lut (ColorModel), threshold, min&max are * also set for the FloatProcessor * @param channelNumber Ignored (needed for compatibility with ColorProcessor.toFloat) * @param fp Here a FloatProcessor can be supplied, or null. The FloatProcessor * is overwritten by this method (re-using its pixels array * improves performance). * @return A FloatProcessor with the converted image data */ public FloatProcessor toFloat(int channelNumber, FloatProcessor fp) { int size = width*height; if (fp == null || fp.getWidth()!=width || fp.getHeight()!=height) fp = new FloatProcessor(width, height, new float[size], cm); float[] fPixels = (float[])fp.getPixels(); for (int i=0; i<size; i++) fPixels[i] = pixels[i]&0xffff; fp.setRoi(getRoi()); fp.setMask(mask); fp.setMinAndMax(getMin(), getMax()); fp.setThreshold(minThreshold, maxThreshold, ImageProcessor.NO_LUT_UPDATE); return fp; }
/** Returns a FloatProcessor with the same image, no scaling or calibration * (pixel values 0 to 65535). * The roi, mask, lut (ColorModel), threshold, min&max are * also set for the FloatProcessor * @param channelNumber Ignored (needed for compatibility with ColorProcessor.toFloat) * @param fp Here a FloatProcessor can be supplied, or null. The FloatProcessor * is overwritten by this method (re-using its pixels array * improves performance). * @return A FloatProcessor with the converted image data */ public FloatProcessor toFloat(int channelNumber, FloatProcessor fp) { int size = width*height; if (fp == null || fp.getWidth()!=width || fp.getHeight()!=height) fp = new FloatProcessor(width, height, new float[size], cm); float[] fPixels = (float[])fp.getPixels(); for (int i=0; i<size; i++) fPixels[i] = pixels[i]&0xffff; fp.setRoi(getRoi()); fp.setMask(mask); fp.setMinAndMax(getMin(), getMax()); fp.setThreshold(minThreshold, maxThreshold, ImageProcessor.NO_LUT_UPDATE); return fp; }
fp = toFloat(channelNumber, fp); fp.setInterpolationMethod(interpolationMethod); fp.setRoi(getRoi()); String msg = showStatus?" ("+(channelNumber+1)+"/"+channels+")":null; FloatProcessor fp2 = fp.downsize(dstWidth, dstHeight, msg);
fp = toFloat(channelNumber, fp); fp.setInterpolationMethod(interpolationMethod); fp.setRoi(getRoi()); String msg = showStatus?" ("+(channelNumber+1)+"/"+channels+")":null; FloatProcessor fp2 = fp.downsize(dstWidth, dstHeight, msg);