public final int getHeight() { return ip.getHeight(); }
/** Constructs a ColorBlitter from a ColorProcessor. */ public ColorBlitter(ColorProcessor ip) { this.ip = ip; width = ip.getWidth(); height = ip.getHeight(); pixels = (int[])ip.getPixels(); }
final static private void processColor(final ColorProcessor ip, final int value, final int min, final int max) { final int scale = max - min + 1; final Random rnd = new Random(); final int n = ip.getWidth() * ip.getHeight(); for (int i =0; i < n; ++i) { final int v = ip.get(i); if (v == value) { final int r = rnd.nextInt(scale) + min; final int g = rnd.nextInt(scale) + min; final int b = rnd.nextInt(scale) + min; ip.set(i, (((((0xff << 8) | r) << 8) | g) << 8) | b); } } }
/** Constructs a ColorBlitter from a ColorProcessor. */ public ColorBlitter(ColorProcessor ip) { this.ip = ip; width = ip.getWidth(); height = ip.getHeight(); pixels = (int[])ip.getPixels(); }
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 LongRGBIntegralImage( final ColorProcessor ip ) { this( ( int[] )ip.getPixels(), ip.getWidth(), ip.getHeight() ); }
public MedianCut(ColorProcessor ip) { this((int[])ip.getPixels(), ip.getWidth(), ip.getHeight()); }
final static protected void colorCircle( ColorProcessor ip ) { final int r1 = Math.min( ip.getWidth(), ip.getHeight() ) / 2; for ( int y = 0; y < ip.getHeight(); ++y ) { final float dy = y - ip.getHeight() / 2; for ( int x = 0; x < ip.getWidth(); ++x ) { final float dx = x - ip.getWidth() / 2; final float l = ( float )Math.sqrt( dx * dx + dy * dy ); if ( l > r1 ) ip.putPixel( x, y, 0 ); else ip.putPixel( x, y, colorVector( dx / maxDistance, dy / maxDistance ) ); } } }
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 Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { if (!isDataFlavorSupported(flavor)) throw new UnsupportedFlavorException(flavor); int w = ip.getWidth(); int h = ip.getHeight(); Image img = IJ.getInstance().createImage(w, h); Graphics g = img.getGraphics(); g.drawImage(ip.createImage(), 0, 0, null); g.dispose(); return img; } }, null);
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()); }
void filterIntensity(ImageProcessor ip) { ColorProcessor cp = (ColorProcessor)ip; int width = cp.getWidth(); int height = cp.getHeight(); int size = width*height; byte[] H = new byte[size]; byte[] S = new byte[size]; byte[] B = new byte[size]; cp.getHSB(H, S, B); ImageProcessor ip2 = new ByteProcessor(width, height, B, null); filter(ip2); cp.setHSB(H, S, (byte[])ip2.getPixels()); }
/** Returns an ImageStack with three 8-bit slices, representing hue, saturation and brightness */ public ImageStack getHSBStack() { int width = getWidth(); int height = getHeight(); byte[] H = new byte[width*height]; byte[] S = new byte[width*height]; byte[] B = new byte[width*height]; getHSB(H, S, B); ColorModel cm = getDefaultColorModel(); ImageStack stack = new ImageStack(width, height, cm); stack.addSlice("Hue", H); stack.addSlice("Saturation", S); stack.addSlice("Brightness", B); return stack; }
/** Returns an ImageStack with three 8-bit slices, representing hue, saturation and brightness */ public ImageStack getHSBStack() { int width = getWidth(); int height = getHeight(); byte[] H = new byte[width*height]; byte[] S = new byte[width*height]; byte[] B = new byte[width*height]; getHSB(H, S, B); ColorModel cm = getDefaultColorModel(); ImageStack stack = new ImageStack(width, height, cm); stack.addSlice("Hue", H); stack.addSlice("Saturation", S); stack.addSlice("Brightness", B); return stack; }
private static void fillNoiseRGB(ColorProcessor ip, boolean sp) { int width = ip.getWidth(); int height = ip.getHeight(); ByteProcessor rr = new ByteProcessor(width, height); ByteProcessor gg = new ByteProcessor(width, height); ByteProcessor bb = new ByteProcessor(width, height); if (sp) IJ.showProgress(0.0); rr.add(127); if (sp) IJ.showProgress(0.05); gg.add(127); if (sp) IJ.showProgress(0.10); bb.add(127); if (sp) IJ.showProgress(0.15); rr.noise(31); if (sp) IJ.showProgress(0.40); gg.noise(31); if (sp) IJ.showProgress(0.65); bb.noise(31); if (sp) IJ.showProgress(0.90); if (sp) IJ.showProgress(1.0); ip.setChannel(1,rr); ip.setChannel(2,gg); ip.setChannel(3,bb); }
private static void fillNoiseRGB(ColorProcessor ip, boolean sp) { int width = ip.getWidth(); int height = ip.getHeight(); ByteProcessor rr = new ByteProcessor(width, height); ByteProcessor gg = new ByteProcessor(width, height); ByteProcessor bb = new ByteProcessor(width, height); if (sp) IJ.showProgress(0.0); rr.add(127); if (sp) IJ.showProgress(0.05); gg.add(127); if (sp) IJ.showProgress(0.10); bb.add(127); if (sp) IJ.showProgress(0.15); rr.noise(31); if (sp) IJ.showProgress(0.40); gg.noise(31); if (sp) IJ.showProgress(0.65); bb.noise(31); if (sp) IJ.showProgress(0.90); if (sp) IJ.showProgress(1.0); ip.setChannel(1,rr); ip.setChannel(2,gg); ip.setChannel(3,bb); }