/** Sets a pixel in the image using a 3 element (R, G and B) int array of samples. */ public final void putPixel(int x, int y, int[] iArray) { int r=iArray[0], g=iArray[1], b=iArray[2]; putPixel(x, y, (r<<16)+(g<<8)+b); }
/** Sets a pixel in the image using a 3 element (R, G and B) int array of samples. */ public final void putPixel(int x, int y, int[] iArray) { int r=iArray[0], g=iArray[1], b=iArray[2]; putPixel(x, y, (r<<16)+(g<<8)+b); }
final static protected void colorCircle( ColorProcessor ip ) { final int r1 = Math.min( ip.getWidth(), ip.getHeight() ) / 2; final int r2 = r1 / 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 || l < r2 ) ip.putPixel( x, y, 0 ); else ip.putPixel( x, y, colorVector( dx / l * maxDistance, dy / l * maxDistance ) ); } } }
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 ) ); } } }
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 ) ); } } }
final static protected void colorCircle( ColorProcessor ip ) { final int r1 = Math.min( ip.getWidth(), ip.getHeight() ) / 2; final int r2 = r1 / 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 || l < r2 ) ip.putPixel( x, y, 0 ); else ip.putPixel( x, y, colorVector( dx / l * maxDistance, dy / l * maxDistance ) ); } } }
final static protected void colorCircle( ColorProcessor ip ) { final int r1 = Math.min( ip.getWidth(), ip.getHeight() ) / 2; final int r2 = r1 / 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 || l < r2 ) ip.putPixel( x, y, 0 ); else ip.putPixel( x, y, colorVector( dx / l * maxDistance, dy / l * maxDistance ) ); } } }
final static protected void colorCircle( ColorProcessor ip ) { final int r1 = Math.min( ip.getWidth(), ip.getHeight() ) / 2; final int r2 = r1 / 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 || l < r2 ) ip.putPixel( x, y, 0 ); else ip.putPixel( x, y, colorVector( dx / l * maxDistance, dy / l * maxDistance ) ); } } }
/** * Draw a color circle into a {@link ColorProcessor}. * * @param ip */ final static public void colorCircle( final 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, colorVector( dx / r1, dy / r1 ) ); } } } }
/** * Draw a color circle into a {@link ColorProcessor}. * * @param ip */ final static public void colorCircle( final 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, colorVector( dx / r1, dy / r1 ) ); } } } }
/** Converts a Lab stack into an RGB image. */ public ImagePlus LabToRGB(ImagePlus img) { int w = img.getWidth(); int h = img.getHeight(); ImageStack stack = img.getStack(); FloatProcessor L = (FloatProcessor)stack.getProcessor(1); FloatProcessor a = (FloatProcessor)stack.getProcessor(2); FloatProcessor b = (FloatProcessor)stack.getProcessor(3); ColorProcessor cp = new ColorProcessor(w, h); ColorSpaceConverter converter = new ColorSpaceConverter(); int[] values = new int[3]; double[] dvalues = new double[3]; for (int y=0; y<h; y++) { for (int x=0; x<w; x++) { dvalues[0] = L.getf(x,y); dvalues[1] = a.getf(x,y); dvalues[2] = b.getf(x,y); values = converter.LABtoRGB(dvalues); cp.putPixel(x,y,values); } } ImagePlus img2 = new ImagePlus(img.getTitle(), cp); return img2; }
/** Converts a Lab stack into an RGB image. */ public ImagePlus LabToRGB(ImagePlus img) { int w = img.getWidth(); int h = img.getHeight(); ImageStack stack = img.getStack(); FloatProcessor L = (FloatProcessor)stack.getProcessor(1); FloatProcessor a = (FloatProcessor)stack.getProcessor(2); FloatProcessor b = (FloatProcessor)stack.getProcessor(3); ColorProcessor cp = new ColorProcessor(w, h); ColorSpaceConverter converter = new ColorSpaceConverter(); int[] values = new int[3]; double[] dvalues = new double[3]; for (int y=0; y<h; y++) { for (int x=0; x<w; x++) { dvalues[0] = L.getf(x,y); dvalues[1] = a.getf(x,y); dvalues[2] = b.getf(x,y); values = converter.LABtoRGB(dvalues); cp.putPixel(x,y,values); } } ImagePlus img2 = new ImagePlus(img.getTitle(), cp); return img2; }