/** Performs a convolution operation using the specified kernel. */ public void convolve(float[] kernel, int kernelWidth, int kernelHeight) { ImageProcessor ip2 = convertToFloat(); ip2.setRoi(getRoi()); new ij.plugin.filter.Convolver().convolve(ip2, kernel, kernelWidth, kernelHeight); ip2 = ip2.convertToShort(false); short[] pixels2 = (short[])ip2.getPixels(); System.arraycopy(pixels2, 0, pixels, 0, pixels.length); }
/** Performs a convolution operation using the specified kernel. */ public void convolve(float[] kernel, int kernelWidth, int kernelHeight) { ImageProcessor ip2 = convertToFloat(); ip2.setRoi(getRoi()); new ij.plugin.filter.Convolver().convolve(ip2, kernel, kernelWidth, kernelHeight); ip2 = ip2.convertToShort(false); short[] pixels2 = (short[])ip2.getPixels(); System.arraycopy(pixels2, 0, pixels, 0, pixels.length); }
/** 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; }