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); } } }
ColorProcessor cp = (ColorProcessor)ip; for (int i = 0; i < rect.width; i++) { values[i] = cp.get(rect.x + i, rect.y + 0) & 0xffffff; values[i + rect.width] = cp.get(rect.x + i, rect.y + rect.height - 1) & 0xffffff; values[i + 2 * rect.width - 1] = cp.get(rect.x + 0, rect.y + i) & 0xffffff; values[i + 2 * rect.width - 1 + rect.height - 2] = cp.get(rect.x + rect.width - 1, rect.y + i) & 0xffffff;
final int it = target.get( x, y ); final int f_raw = alpha.getPixelInterpolated( t[ 0 ], t[ 1 ] ); final double f = f_raw / 255.0;
/** * Prints the content of the input color image on the console. This can be * used for debugging (small) images. * * @param image * the color image to display on the console */ public static final void print(ColorProcessor image) { for (int y = 0; y < image.getHeight(); y++) { for (int x = 0; x < image.getWidth(); x++) { int intCode = image.get(x, y); int r = (intCode & 0xFF0000) >> 16; int g = (intCode & 0xFF00) >> 8; int b = (intCode & 0xFF); System.out.print(String.format("(%3d,%3d,%3d) ", r, g, b)); } System.out.println(""); } }
int intCode = rgb.get(x, y); red.set(x, y, (intCode >> 16) & 0x00FF); green.set(x, y, (intCode >> 8) & 0x00FF);
@Test public final void testLabelToRGB_ImageProcessorByteArrayColor() { // create a byte processor containing four labels ImageProcessor image = new ByteProcessor(10, 10); for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { image.set(x + 1, y + 1, 1); image.set(x + 5, y + 1, 2); image.set(x + 1, y + 5, 3); image.set(x + 5, y + 5, 4); } } // create LUT and background color byte[][] lut = CommonLabelMaps.GOLDEN_ANGLE.computeLut(4, false); Color bgColor = Color.WHITE; // compute color image from labels ColorProcessor colorImage = LabelImages.labelToRgb(image, lut, bgColor); Assert.assertNotEquals(0, colorImage.get(2, 2)); Assert.assertNotEquals(0, colorImage.get(6, 2)); Assert.assertNotEquals(0, colorImage.get(2, 6)); Assert.assertNotEquals(0, colorImage.get(6, 6)); }
int intCode = rgb.get(x, y); red.set(x, y, (intCode >> 16) & 0x00FF); green.set(x, y, (intCode >> 8) & 0x00FF);