public RGBApply( final ColorProcessor 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 = ( int[] )ip.getPixels(); }
public RGBApply( final ColorProcessor 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 = ( int[] )ip.getPixels(); }
private void loadPixels(float [][] i, ColorProcessor cp, int width, int height) { int [] ii = (int []) cp.getPixels(); // RGB 32 bit image image deserves separate treatment. Take brightness from RGB value. for (int y = 0; y < height; y++) { int offset = y * width; for (int x = 0; x < width; x++) { int c = ii[offset + x]; int r = (c&0xff0000)>>16; int g = (c&0xff00)>>8; int b = c&0xff; i[y][x] = (float) (r*0.30 + g*0.59 + b*0.11); } } } private void loadPixels(float [][] i, ByteProcessor bp, int width, int height)
private void loadPixels(float [][] i, ColorProcessor cp, int width, int height) { int [] ii = (int []) cp.getPixels(); // RGB 32 bit image image deserves separate treatment. Take brightness from RGB value. for (int y = 0; y < height; y++) { int offset = y * width; for (int x = 0; x < width; x++) { int c = ii[offset + x]; int r = (c&0xff0000)>>16; int g = (c&0xff00)>>8; int b = c&0xff; i[y][x] = (float) (r*0.30 + g*0.59 + b*0.11); } } } private void loadPixels(float [][] i, ByteProcessor bp, int width, int height)
@Override public void imageUpdated(ImagePlus image) { if(image != imp) return; WritableRaster newRaster = bImage.getRaster(); byte[] byteData = ((DataBufferByte) newRaster.getDataBuffer()).getData(); int[] pixels = (int[])bProcessor.getPixels(); for(int i = 0, j = 0; i < pixels.length; i++) { int c = pixels[i]; int r = (c & 0xff0000) >> 16; int g = (c & 0xff00) >> 8; int b = c & 0xff; int a = Math.min(255, r + g + b); byteData[j++] = (byte)r; byteData[j++] = (byte)g; byteData[j++] = (byte)b; byteData[j++] = (byte)a; } bComp.updateData(updater, 0, 0, w, h); }
/** Constructs a ColorBlitter from a ColorProcessor. */ public ColorBlitter(ColorProcessor ip) { this.ip = ip; width = ip.getWidth(); height = ip.getHeight(); pixels = (int[])ip.getPixels(); }
/** Constructs a ColorBlitter from a ColorProcessor. */ public ColorBlitter(ColorProcessor ip) { this.ip = ip; width = ip.getWidth(); height = ip.getHeight(); pixels = (int[])ip.getPixels(); }
public LongRGBIntegralImage( final ColorProcessor ip ) { this( ( int[] )ip.getPixels(), ip.getWidth(), ip.getHeight() ); }
public MedianCut(ColorProcessor ip) { this((int[])ip.getPixels(), ip.getWidth(), ip.getHeight()); }
public LongRGBIntegralImage( final ColorProcessor ip ) { this( ( int[] )ip.getPixels(), ip.getWidth(), ip.getHeight() ); }
public MedianCut(ColorProcessor ip) { this((int[])ip.getPixels(), ip.getWidth(), ip.getHeight()); }
public static void process(ColorProcessor ip) { int w = ip.getWidth(), h = ip.getHeight(); int[] pixels = (int[])ip.getPixels(); for (int j = 0; j < h; j++) for (int i = 0; i < w; i++) { int value = pixels[i + j * w]; int red = (value >> 16) & 0xff; int green = (value >> 8) & 0xff; int blue = value & 0xff; if (false && blue > 16) continue; pixels[i + j * w] = (red << 16) | (green << 8) | red; } } }
public ColorStats(ColorProcessor cp, byte[] mask, Rectangle rect) { int [] pixels=(int[])cp.getPixels(); int width=cp.getWidth(); histogram= getHistogram(width, pixels,mask, rect); //ImageProcessor ipmask = imp.getMask(); //new ImagePlus("ROI",ipmask).show(); calculateStatistics(histogram); }
public ColorStats(ColorProcessor cp, Rectangle rect) { int [] pixels=(int[])cp.getPixels(); int width=cp.getWidth(); histogram = getHistogram(width,pixels, rect); calculateStatistics(histogram); }
private void writeFourChannelsWithAlpha(ImagePlus imp, String path) throws Exception { ImageStack stack = imp.getStack(); int w=imp.getWidth(), h=imp.getHeight(); ImagePlus imp2 = new ImagePlus("", new ColorProcessor(w,h)); ColorProcessor cp = (ColorProcessor)imp2.getProcessor(); for (int channel=1; channel<=4; channel++) cp.setChannel(channel, (ByteProcessor)stack.getProcessor(channel)); BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); WritableRaster raster = bi.getRaster(); raster.setDataElements(0, 0, w, h, cp.getPixels()); ImageIO.write(bi, "png", new File(path)); }
private void writeFourChannelsWithAlpha(ImagePlus imp, String path) throws Exception { ImageStack stack = imp.getStack(); int w=imp.getWidth(), h=imp.getHeight(); ImagePlus imp2 = new ImagePlus("", new ColorProcessor(w,h)); ColorProcessor cp = (ColorProcessor)imp2.getProcessor(); for (int channel=1; channel<=4; channel++) cp.setChannel(channel, (ByteProcessor)stack.getProcessor(channel)); BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); WritableRaster raster = bi.getRaster(); raster.setDataElements(0, 0, w, h, cp.getPixels()); ImageIO.write(bi, "png", new File(path)); }
static private final ImageBytes asBytes(final ColorProcessor cp) { return new ImageBytes(P.asRGBBytes((int[])cp.getPixels()), cp.getWidth(), cp.getHeight()); }
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) {
final static protected FloatProcessor createMask( final ColorProcessor source ) { final FloatProcessor mask = new FloatProcessor( source.getWidth(), source.getHeight() ); final int maskColor = 0x0000ff00; final int[] sourcePixels = ( int[] )source.getPixels(); final int n = sourcePixels.length; final float[] maskPixels = ( float[] )mask.getPixels(); for ( int i = 0; i < n; ++i ) { final int sourcePixel = sourcePixels[ i ] & 0x00ffffff; if ( sourcePixel == maskColor ) maskPixels[ i ] = 0; else maskPixels[ i ] = 1; } return mask; }
static private final ImageBytes asBytes(final ColorProcessor cp, final ByteProcessor mask) { return new ImageBytes(P.asRGBABytes((int[])cp.getPixels(), (byte[])mask.getPixels(), null), cp.getWidth(), cp.getHeight()); }