/** 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()); }
final static protected ShortProcessor mapIntensities( final PatchIntensityRange pir, final double min, final double max ) { final double a = 65535.0 / ( max - min ); final ImageProcessor source = pir.patch.getImageProcessor(); final short[] targetPixels = new short[ source.getWidth() * source.getHeight() ]; for ( int i = 0; i < targetPixels.length; ++i ) { targetPixels[ i ] = ( short )Math.max( 0, Math.min( 65535, Math.round( ( ( source.getf( i ) - pir.patch.getMin() ) / pir.a - min ) * a ) ) ); } final ShortProcessor target = new ShortProcessor( source.getWidth(), source.getHeight(), targetPixels, null ); target.setMinAndMax( -min * a, ( 1.0 - min ) * a ); return target; }
/** 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) { setValue(bestIndex); setMinAndMax(0.0,255.0); } else if (bestIndex==0 && getMin()>0.0 && (color.getRGB()&0xffffff)==0) { if (isSigned16Bit()) setValue(32768); else setValue(0.0); } else fgColor = (int)(getMin() + (getMax()-getMin())*(bestIndex/255.0)); }
/** 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) { setValue(bestIndex); setMinAndMax(0.0,255.0); } else if (bestIndex==0 && getMin()>0.0 && (color.getRGB()&0xffffff)==0) { if (isSigned16Bit()) setValue(32768); else setValue(0.0); } else fgColor = (int)(getMin() + (getMax()-getMin())*(bestIndex/255.0)); }
sp.setMinAndMax( minI, maxI ); if (0 != backgroundValue) { sp.setValue(backgroundValue);
final Rectangle box = new Rectangle( x0, y0, tileWidth, tileHeight ); final ShortProcessor sp = new ShortProcessor( tileWidth, tileHeight ); sp.setMinAndMax( minI, maxI ); for ( final PatchIntensityRange pir : patchIntensityRanges )
distMap.setMinAndMax(0, maxVal);
distMap.setMinAndMax(0, maxVal);
b.setMinAndMax( min, max );