private void loadPixels(float [][] i, ByteProcessor bp, int width, int height) { byte [] b = (byte []) bp.getPixels(); for (int y = 0; y < height; y++) { int offset = y * width; for (int x = 0; x < width; x++) i[y][x] = (float) (b[offset + x] & 0xff); } } private void loadPixels(float [][] i, ShortProcessor sp, int width, int height)
private void loadPixels(float [][] i, ByteProcessor bp, int width, int height) { byte [] b = (byte []) bp.getPixels(); for (int y = 0; y < height; y++) { int offset = y * width; for (int x = 0; x < width; x++) i[y][x] = (float) (b[offset + x] & 0xff); } } private void loadPixels(float [][] i, ShortProcessor sp, int width, int height)
public ByteApply( final ByteProcessor ip, final ByteProcessor src, final ByteProcessor dst, final ByteProcessor mask, final int boxXMin, final int boxYMin, final int boxXMax, final int boxYMax ) throws Exception { super( ip, src, dst, mask, boxXMin, boxYMin, boxXMax, boxYMax ); ipPixels = ( byte[] )ip.getPixels(); }
/** * Fill the ByteProcessor with provided value. * * @param bp buffer * @param val value to fill buffer with */ public static void fill (ByteProcessor bp, int val) { final byte[] pixels = (byte[]) bp.getPixels(); Arrays.fill(pixels, (byte) val); }
final static public void fillWithNoise( final ByteProcessor bp ) { final byte[] data = ( byte[] )bp.getPixels(); final Random random = new Random( System.nanoTime() ); for ( int i = 0; i < data.length; ++i ) data[ i ] = ( byte )random.nextInt( 256 ); }
final static public void fillWithNoise( final ByteProcessor bp ) { final byte[] data = ( byte[] )bp.getPixels(); final Random random = new Random( System.nanoTime() ); for ( int i = 0; i < data.length; ++i ) data[ i ] = ( byte )random.nextInt( 256 ); }
/** Returns the specified plane (1=red, 2=green, 3=blue, 4=alpha) as a byte array. */ public byte[] getChannel(int channel) { ByteProcessor bp = getChannel(channel, null); return (byte[])bp.getPixels(); }
/** Returns the specified plane (1=red, 2=green, 3=blue, 4=alpha) as a byte array. */ public byte[] getChannel(int channel) { ByteProcessor bp = getChannel(channel, null); return (byte[])bp.getPixels(); }
public ByteAccessor(ByteProcessor ip) { w = ip.getWidth(); h = ip.getHeight(); pixels = (byte[])ip.getPixels(); }
/** Constructs a ByteBlitter from a ByteProcessor. */ public ByteBlitter(ByteProcessor ip) { this.ip = ip; width = ip.getWidth(); height = ip.getHeight(); pixels = (byte[])ip.getPixels(); }
public GenericAccumulator(int x, int y, ByteProcessor mask) { this.x = x; this.y = y; width = mask.getWidth(); height = mask.getHeight(); pixels = (byte[])mask.getPixels(); }
/** Constructs a ByteBlitter from a ByteProcessor. */ public ByteBlitter(ByteProcessor ip) { this.ip = ip; width = ip.getWidth(); height = ip.getHeight(); pixels = (byte[])ip.getPixels(); }
private void initHistogram(ByteProcessor image) { byte[] pixels=(byte[])image.getPixels(); int w=image.getWidth(),h=image.getHeight(); for(int i=0;i<w*h;i++) { int value=pixels[i]; if(value<0) value+=256; values[value]++; } }
/** Returns the specified plane (1=red, 2=green, 3=blue, 4=alpha) as a ByteProcessor. */ public ByteProcessor getChannel(int channel, ByteProcessor bp) { int size = width*height; if (bp == null || bp.getWidth()!=width || bp.getHeight()!=height) bp = new ByteProcessor(width, height); byte[] bPixels = (byte[])bp.getPixels(); int shift = 16 - 8*(channel-1); if (channel==4) shift=24; for (int i=0; i<size; i++) bPixels[i] = (byte)(pixels[i]>>shift); return bp; }
public void evaluate(ByteProcessor ip, int z) { int w = ip.getWidth(); int h = ip.getHeight(); byte[] p = (byte[])ip.getPixels(); for (int j = 0; j < h; j++) for (int i = 0; i < w; i++) { double v0 = implicitFunction.evaluate(i, j, z); p[i + j * w] = (byte)(v0 > 0 ? 255 : 0); } }
public BufferedImage createImage() { bProcessor = (ByteProcessor)imp.getProcessor(); byte[] pixels = (byte[])bProcessor.getPixels(); IndexColorModel cm = getDefaultColorModel(); SampleModel sm = cm.createCompatibleSampleModel(w, h); DataBufferByte db = new DataBufferByte(pixels, w * h, 0); WritableRaster raster = Raster.createWritableRaster(sm, db, null); return new BufferedImage(cm, raster, false, null); }
final static protected FloatProcessor scaleByte( final ByteProcessor bp ) { final FloatProcessor fp = new FloatProcessor( bp.getWidth(), bp.getHeight() ); final byte[] bytes = ( byte[] )bp.getPixels(); final float[] floats = ( float[] )fp.getPixels(); for ( int i = 0; i < bytes.length; ++i ) floats[ i ] = ( bytes[ i ] & 0xff ) / 255.0f; return fp; }
/** Creates a BinaryProcessor from a ByteProcessor. The ByteProcessor must contain a binary image (pixels values are either 0 or 255). Backgound is assumed to be white. */ public BinaryProcessor(ByteProcessor ip) { super(ip.getWidth(), ip.getHeight(), (byte[])ip.getPixels(), ip.getColorModel()); setRoi(ip.getRoi()); parent = ip; }
/** Creates a BinaryProcessor from a ByteProcessor. The ByteProcessor must contain a binary image (pixels values are either 0 or 255). Backgound is assumed to be white. */ public BinaryProcessor(ByteProcessor ip) { super(ip.getWidth(), ip.getHeight(), (byte[])ip.getPixels(), ip.getColorModel()); setRoi(ip.getRoi()); parent = ip; }
/** A method that circumvents the findMinAndMax when creating a float processor from an existing processor. Ignores color calibrations and does no scaling at all. */ static public final FloatProcessor fastConvertToFloat(final ByteProcessor ip) { final byte[] pix = (byte[])ip.getPixels(); final float[] data = new float[pix.length]; for (int i=0; i<pix.length; i++) data[i] = pix[i]&0xff; final FloatProcessor fp = new FloatProcessorT2(ip.getWidth(), ip.getHeight(), data, ip.getColorModel(), ip.getMin(), ip.getMax()); return fp; } /** A method that circumvents the findMinAndMax when creating a float processor from an existing processor. Ignores color calibrations and does no scaling at all. */