public void snapshot() { snapshotWidth=width; snapshotHeight=height; snapshotMin=(float)getMin(); snapshotMax=(float)getMax(); if (snapshotPixels==null || (snapshotPixels!=null && snapshotPixels.length!=pixels.length)) snapshotPixels = new float[width * height]; System.arraycopy(pixels, 0, snapshotPixels, 0, width*height); }
public void snapshot() { snapshotWidth=width; snapshotHeight=height; snapshotMin=(float)getMin(); snapshotMax=(float)getMax(); if (snapshotPixels==null || (snapshotPixels!=null && snapshotPixels.length!=pixels.length)) snapshotPixels = new float[width * height]; System.arraycopy(pixels, 0, snapshotPixels, 0, width*height); }
/** Sets the foreground fill/draw color. */ public void setColor(Color color) { drawingColor = color; int bestIndex = getBestIndex(color); if (bestIndex>0 && getMin()==0.0 && getMax()==0.0) { fillColor = bestIndex; setMinAndMax(0.0,255.0); } else if (bestIndex==0 && getMin()>0.0 && (color.getRGB()&0xffffff)==0) fillColor = 0f; else fillColor = (float)(getMin() + (getMax()-getMin())*(bestIndex/255.0)); }
private byte[] create8BitImage(boolean thresholding) { int size = width*height; if (pixels8==null) pixels8 = new byte[size]; double value; int ivalue; double min2 = getMin(); double max2=getMax(); double scale = 255.0/(max2-min2); int maxValue = thresholding?254:255; if (ij.IJ.debugMode) ij.IJ.log("create8BitImage: "+min2+" "+max2+" "+scale); for (int i=0; i<size; i++) { value = pixels[i]-min2; if (value<0.0) value=0.0; ivalue = (int)(value*scale+0.5); if (ivalue>maxValue) ivalue = maxValue; pixels8[i] = (byte)ivalue; } return pixels8; }
public NormalizeLocalContrast( final FloatProcessor fp ) { super( fp ); fpOriginal = ( FloatProcessor )fp.duplicate(); fpOriginal.setMinAndMax( fp.getMin(), fp.getMax() ); }
/** Sets the foreground fill/draw color. */ public void setColor(Color color) { drawingColor = color; int bestIndex = getBestIndex(color); if (bestIndex>0 && getMin()==0.0 && getMax()==0.0) { fillColor = bestIndex; setMinAndMax(0.0,255.0); } else if (bestIndex==0 && getMin()>0.0 && (color.getRGB()&0xffffff)==0) fillColor = 0f; else fillColor = (float)(getMin() + (getMax()-getMin())*(bestIndex/255.0)); }
private byte[] create8BitImage(boolean thresholding) { int size = width*height; if (pixels8==null) pixels8 = new byte[size]; double value; int ivalue; double min2 = getMin(); double max2=getMax(); double scale = 255.0/(max2-min2); int maxValue = thresholding?254:255; if (ij.IJ.debugMode) ij.IJ.log("create8BitImage: "+min2+" "+max2+" "+scale); for (int i=0; i<size; i++) { value = pixels[i]-min2; if (value<0.0) value=0.0; ivalue = (int)(value*scale+0.5); if (ivalue>maxValue) ivalue = maxValue; pixels8[i] = (byte)ivalue; } return pixels8; }
public NormalizeLocalContrast( final FloatProcessor fp ) { super( fp ); fpOriginal = ( FloatProcessor )fp.duplicate(); fpOriginal.setMinAndMax( fp.getMin(), fp.getMax() ); }
/** Sets the pixels from a FloatProcessor, no scaling. * Also the min&max values are taken from the FloatProcessor. * @param channelNumber Ignored (needed for compatibility with ColorProcessor.toFloat) * @param fp The FloatProcessor where the image data are read from. */ public void setPixels(int channelNumber, FloatProcessor fp) { float[] fPixels = (float[])fp.getPixels(); float value; int size = width*height; for (int i=0; i<size; i++) { value = fPixels[i] + 0.5f; if (value<0f) value = 0f; if (value>255f) value = 255f; pixels[i] = (byte)value; } setMinAndMax(fp.getMin(), fp.getMax()); }
/** Sets the pixels from a FloatProcessor, no scaling. * Also the min&max values are taken from the FloatProcessor. * @param channelNumber Ignored (needed for compatibility with ColorProcessor.toFloat) * @param fp The FloatProcessor where the image data are read from. */ public void setPixels(int channelNumber, FloatProcessor fp) { float[] fPixels = (float[])fp.getPixels(); float value; int size = width*height; for (int i=0; i<size; i++) { value = fPixels[i] + 0.5f; if (value<0f) value = 0f; if (value>255f) value = 255f; pixels[i] = (byte)value; } setMinAndMax(fp.getMin(), fp.getMax()); }
/** Sets the pixels from a FloatProcessor, no scaling. * Also the min&max values are taken from the FloatProcessor. * @param channelNumber Ignored (needed for compatibility with ColorProcessor.toFloat) * @param fp The FloatProcessor where the image data are read from. */ public void setPixels(int channelNumber, FloatProcessor fp) { float[] fPixels = (float[])fp.getPixels(); float value; int size = width*height; for (int i=0; i<size; i++) { value = fPixels[i] + 0.5f; if (value<0f) value = 0f; if (value>65535f) value = 65535f; pixels[i] = (short)value; } setMinAndMax(fp.getMin(), fp.getMax()); }
/** Sets the pixels from a FloatProcessor, no scaling. * Also the min&max values are taken from the FloatProcessor. * @param channelNumber Ignored (needed for compatibility with ColorProcessor.toFloat) * @param fp The FloatProcessor where the image data are read from. */ public void setPixels(int channelNumber, FloatProcessor fp) { float[] fPixels = (float[])fp.getPixels(); float value; int size = width*height; for (int i=0; i<size; i++) { value = fPixels[i] + 0.5f; if (value<0f) value = 0f; if (value>65535f) value = 65535f; pixels[i] = (short)value; } setMinAndMax(fp.getMin(), fp.getMax()); }
/** Returns a new, blank FloatProcessor with the specified width and height. */ public ImageProcessor createProcessor(int width, int height) { ImageProcessor ip2 = new FloatProcessor(width, height, new float[width*height], getColorModel()); ip2.setMinAndMax(getMin(), getMax()); ip2.setInterpolationMethod(interpolationMethod); return ip2; }
public FloatProcessorT2(final FloatProcessor fp) { this(fp.getWidth(), fp.getHeight(), (float[])fp.getPixels(), fp.getColorModel(), fp.getMin(), fp.getMax()); } public FloatProcessorT2(final ByteProcessor bp) {
/** Returns a new, blank FloatProcessor with the specified width and height. */ public ImageProcessor createProcessor(int width, int height) { ImageProcessor ip2 = new FloatProcessor(width, height, new float[width*height], getColorModel()); ip2.setMinAndMax(getMin(), getMax()); ip2.setInterpolationMethod(interpolationMethod); return ip2; }
/** Sets the pixels, and min&max values from a FloatProcessor. * Also the values are taken from the FloatProcessor. * @param channelNumber Ignored (needed for compatibility with ColorProcessor.toFloat) * @param fp The FloatProcessor where the image data are read from. */ public void setPixels(int channelNumber, FloatProcessor fp) { if (fp.getPixels() != getPixels()) setPixels(fp.getPixels()); setMinAndMax(fp.getMin(), fp.getMax()); }
/** Sets the pixels, and min&max values from a FloatProcessor. * Also the values are taken from the FloatProcessor. * @param channelNumber Ignored (needed for compatibility with ColorProcessor.toFloat) * @param fp The FloatProcessor where the image data are read from. */ public void setPixels(int channelNumber, FloatProcessor fp) { if (fp.getPixels() != getPixels()) setPixels(fp.getPixels()); setMinAndMax(fp.getMin(), fp.getMax()); }
private FloatProcessor readMask(String imagePath) { if((imagePath != null) && (imagePath.trim().length() > 0)) { ImagePlus imp = IJ.openImage(imagePath); if(imp != null) { // ensure that the maximum value cannot be more than 1.0 ! FloatProcessor fmask = (FloatProcessor) imp.getProcessor().convertToFloat(); float min = 0; float max = (float) fmask.getMax(); if(max > 0) { for(int x = 0; x < fmask.getWidth(); x++) { for(int y = 0; y < fmask.getHeight(); y++) { fmask.setf(x, y, (fmask.getf(x, y) - min) / (max - min)); } } } return fmask; } } return ImageMath.ones(width, height); }
/** * Normalize float image so the pixel are between 0 and 1 * @param fp input image */ public static void normalize01( FloatProcessor fp ) { fp.resetMinAndMax(); double max = fp.getMax(); double min = fp.getMin(); double scale = max>min?1.0/(max-min):1.0; int size = fp.getWidth()*fp.getHeight(); float[] pixels = (float[])fp.getPixels(); double v; for (int i=0; i<size; i++) { v = pixels[i] - min; if (v<0.0) v = 0.0; v *= scale; if (v>1.0) v = 1.0; pixels[i] = (float)v; } }
/** * Normalize float image so the pixel are between 0 and 1 * @param fp input image */ public static void normalize01( FloatProcessor fp ) { fp.resetMinAndMax(); double max = fp.getMax(); double min = fp.getMin(); double scale = max>min?1.0/(max-min):1.0; int size = fp.getWidth()*fp.getHeight(); float[] pixels = (float[])fp.getPixels(); double v; for (int i=0; i<size; i++) { v = pixels[i] - min; if (v<0.0) v = 0.0; v *= scale; if (v>1.0) v = 1.0; pixels[i] = (float)v; } }