public static void drawFeatureDescriptor( final FloatProcessor fp, final Feature f ) { fp.setMinAndMax( 0.0, 1.0 ); final int w = ( int )Math.sqrt( f.descriptor.length ); for ( int y = 0; y < w; ++ y ) for ( int x = 0; x < w; ++x ) fp.setf( x, y, f.descriptor[ y * w + x ] ); }
public static void drawFeatureDescriptor( final FloatProcessor fp, final Feature f ) { fp.setMinAndMax( 0.0, 1.0 ); final int w = ( int )Math.sqrt( f.descriptor.length ); for ( int y = 0; y < w; ++ y ) for ( int x = 0; x < w; ++x ) fp.setf( x, y, f.descriptor[ y * w + x ] ); }
public FloatProcessorT2(final ByteProcessor bp) { this((FloatProcessor)bp.convertToFloat()); super.setMinAndMax(0, 255); // to avoid looking for it when min,max are perfectly known. }
/** Calculates a 16-bit grayscale Euclidean Distance Map for a binary 8-bit image. * Each foreground (nonzero) pixel in the binary image is assigned a value equal to * its distance from the nearest background (zero) pixel, multiplied by EDM.ONE. * For compatibility with previous versions of ImageJ only. */ public ShortProcessor make16bitEDM (ImageProcessor ip) { FloatProcessor floatEdm = makeFloatEDM(ip, 0, false); floatEdm.setMinAndMax(0, 65535./ONE); return (ShortProcessor)floatEdm.convertToShort(true); }
/** Calculates a 16-bit grayscale Euclidean Distance Map for a binary 8-bit image. * Each foreground (nonzero) pixel in the binary image is assigned a value equal to * its distance from the nearest background (zero) pixel, multiplied by EDM.ONE. * For compatibility with previous versions of ImageJ only. */ public ShortProcessor make16bitEDM (ImageProcessor ip) { FloatProcessor floatEdm = makeFloatEDM(ip, 0, false); floatEdm.setMinAndMax(0, 65535./ONE); return (ShortProcessor)floatEdm.convertToShort(true); }
/** Calculates a 16-bit grayscale Euclidean Distance Map for a binary 8-bit image. * Each foreground (nonzero) pixel in the binary image is assigned a value equal to * its distance from the nearest background (zero) pixel, multiplied by ImageJ_EDM.ONE. * For compatibility with previous versions of ImageJ only. */ public ShortProcessor make16bitEDM (ImageProcessor ip) { FloatProcessor floatEdm = makeFloatEDM(ip, 0, false); floatEdm.setMinAndMax(0, 65535./ONE); return (ShortProcessor)floatEdm.convertToShort(true); }
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() ); }
public FloatProcessorT2(final ColorProcessor cp, final int channel) { this(cp.getWidth(), cp.getHeight(), 0, 255); final int[] c = (int[])cp.getPixels(); int bitmask = 0; int shift = 0; switch (channel) { case 0: bitmask = 0x00ff0000; shift = 16; break; // red case 1: bitmask = 0x0000ff00; shift = 8; break; // green case 2: bitmask = 0x000000ff; break; // blue } final float[] pixels = (float[])this.getPixels(); // I luv pointlessly private fields for (int i=0; i<pixels.length; i++) pixels[i] = ((c[i] & bitmask)>>shift); super.setMinAndMax(0, 255); // we know them } public FloatProcessorT2(final FloatProcessor fp) {
/** 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 static ImagePlus FloatArrayToImagePlus(FloatArray2D image, String name, float min, float max) { ImagePlus imp = IJ.createImage(name,"32-Bit Black", image.width, image.height, 1); FloatProcessor ip = (FloatProcessor)imp.getProcessor(); FloatArrayToFloatProcessor(ip, image); if (min == max) ip.resetMinAndMax(); else ip.setMinAndMax(min, max); imp.updateAndDraw(); return imp; }
/** 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)); }
/** 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()); }
final static public ImagePlus FloatArrayToImagePlus( final FloatArray2D image, final String name, final float min, final float max ) { final ImagePlus imp = IJ.createImage( name, "32-Bit Black", image.width, image.height, 1 ); final FloatProcessor ip = ( FloatProcessor )imp.getProcessor(); floatArray2DToFloatProcessor( image, ip ); if ( min == max ) ip.resetMinAndMax(); else ip.setMinAndMax( min, max ); imp.updateAndDraw(); return imp; }
final static public ImagePlus FloatArrayToImagePlus( final FloatArray2D image, final String name, final float min, final float max ) { final ImagePlus imp = IJ.createImage( name, "32-Bit Black", image.width, image.height, 1 ); final FloatProcessor ip = ( FloatProcessor )imp.getProcessor(); floatArray2DToFloatProcessor( image, ip ); if ( min == max ) ip.resetMinAndMax(); else ip.setMinAndMax( min, max ); imp.updateAndDraw(); return imp; }
/** 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()); }
/** * This method converts my FloatArray2D to an ImageJ ImagePlus * * @param image The image as FloatArray2D * @param name The name of the ImagePlus * @param min Lowest brightness value that will be displayed (see Brightness&Contrast in Imagej) * @param max Highest brightness value that will be displayed (set both to zero for automatic) * @return ImagePlus The ImageJ image */ public static ImagePlus FloatArrayToImagePlus(FloatArray2D image, String name, float min, float max) { ImagePlus imp = IJ.createImage(name,"32-Bit Black", image.width, image.height, 1); FloatProcessor ip = (FloatProcessor)imp.getProcessor(); FloatArrayToFloatProcessor(ip, image); if (min == max) ip.resetMinAndMax(); else ip.setMinAndMax(min, max); imp.updateAndDraw(); return imp; }
/** * This method converts my FloatArray2D to an ImageJ ImagePlus * * @param image The image as FloatArray2D * @param name The name of the ImagePlus * @param min Lowest brightness value that will be displayed (see Brightness&Contrast in Imagej) * @param max Highest brightness value that will be displayed (set both to zero for automatic) * @return ImagePlus The ImageJ image * * @author Stephan Preibisch */ private ImagePlus FloatArrayToImagePlus(FloatArray2D image, String name, float min, float max) { ImagePlus imp = IJ.createImage(name, "32-Bit Black", image.width, image.height, 1); FloatProcessor ip = (FloatProcessor) imp.getProcessor(); FloatArrayToFloatProcessor(ip, image); if (min == max) ip.resetMinAndMax(); else ip.setMinAndMax(min, max); imp.updateAndDraw(); return imp; }
/** 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 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; }