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)); }
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)); }
@Override final public void apply( final int cellXMin, final int cellYMin, final int cellXMax, final int cellYMax ) { final int xMin = Math.max( boxXMin, cellXMin ); final int yMin = Math.max( boxYMin, cellYMin ); final int xMax = Math.min( boxXMax, cellXMax ); final int yMax = Math.min( boxYMax, cellYMax ); final float min = ( float )ip.getMin(); for ( int y = yMin; y < yMax; ++y ) { int i = y * width + xMin; for ( int x = xMin; x < xMax; ++x ) { final float m = ( maskPixels[ i ] & 0xff ) / 255.0f; final float v = ipPixels[ i ]; final float vSrc = srcPixels[ i ] & 0xff; final float a; if ( vSrc == 0 ) a = 1.0f; else a = ( float )( dstPixels[ i ] & 0xff ) / vSrc; ipPixels[ i ] = m * ( a * ( v - min ) + min - v ) + v; ++i; } } } }
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; }
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() ); }
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()); }
/** * 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; } }