@Override public ColorModel getCurrentColorModel() { record("getCurrentColorModel"); return proc.getCurrentColorModel(); }
@Override public ColorModel getCurrentColorModel() { record("getCurrentColorModel"); return proc.getCurrentColorModel(); }
/** Write the color table entries (for 8 bit grayscale or indexed color). * Byte order or LUT entries: blue byte, green byte, red byte, 0 byte */ private void writeLUT(ImageProcessor ip) throws IOException { IndexColorModel cm = (IndexColorModel)(ip.getCurrentColorModel()); int mapSize = cm.getMapSize(); byte[] lutWrite = new byte[4*256]; for (int i = 0; i<256; i++) { if (i<mapSize) { lutWrite[4*i] = (byte)cm.getBlue(i); lutWrite[4*i+1] = (byte)cm.getGreen(i); lutWrite[4*i+2] = (byte)cm.getRed(i); lutWrite[4*i+3] = (byte)0; } } raFile.write(lutWrite); }
/** Write the color table entries (for 8 bit grayscale or indexed color). * Byte order or LUT entries: blue byte, green byte, red byte, 0 byte */ private void writeLUT(ImageProcessor ip) throws IOException { IndexColorModel cm = (IndexColorModel)(ip.getCurrentColorModel()); int mapSize = cm.getMapSize(); byte[] lutWrite = new byte[4*256]; for (int i = 0; i<256; i++) { if (i<mapSize) { lutWrite[4*i] = (byte)cm.getBlue(i); lutWrite[4*i+1] = (byte)cm.getGreen(i); lutWrite[4*i+2] = (byte)cm.getRed(i); lutWrite[4*i+3] = (byte)0; } } raFile.write(lutWrite); }
private void setLUTsFromImage(final ImagePlus imp) { switch (imp.getType()) { case ImagePlus.GRAY8: case ImagePlus.COLOR_256: final IndexColorModel cm = (IndexColorModel) imp.getProcessor().getCurrentColorModel(); for (int i = 0; i < 256; i++) { rLUT[i] = cm.getRed(i); gLUT[i] = cm.getGreen(i); bLUT[i] = cm.getBlue(i); aLUT[i] = Math.min(254, (rLUT[i] + gLUT[i] + bLUT[i]) / 3); } break; case ImagePlus.COLOR_RGB: for (int i = 0; i < 256; i++) { rLUT[i] = gLUT[i] = bLUT[i] = i; aLUT[i] = Math.min(254, i); } break; default: throw new IllegalArgumentException("Unsupported image type"); } }
/** Creates a ByteProcessor from an ImageProcessor. 16-bit and 32-bit * pixel data are scaled from min-max to 0-255 if 'scale' is true. * @see ImageProcessor#convertToByteProcessor * @see ImageProcessor#convertToShortProcessor * @see ImageProcessor#convertToFloatProcessor * @see ImageProcessor#convertToColorProcessor */ public ByteProcessor(ImageProcessor ip, boolean scale) { ImageProcessor bp; if (ip instanceof ByteProcessor) bp = ip.duplicate(); else bp = ip.convertToByte(scale); this.width = bp.getWidth(); this.height = bp.getHeight(); resetRoi(); this.pixels = (byte[])bp.getPixels(); this.cm = bp.getCurrentColorModel(); }
/** Creates a ByteProcessor from an ImageProcessor. 16-bit and 32-bit * pixel data are scaled from min-max to 0-255 if 'scale' is true. * @see ImageProcessor#convertToByteProcessor * @see ImageProcessor#convertToShortProcessor * @see ImageProcessor#convertToFloatProcessor * @see ImageProcessor#convertToColorProcessor */ public ByteProcessor(ImageProcessor ip, boolean scale) { ImageProcessor bp; if (ip instanceof ByteProcessor) bp = ip.duplicate(); else bp = ip.convertToByte(scale); this.width = bp.getWidth(); this.height = bp.getHeight(); resetRoi(); this.pixels = (byte[])bp.getPixels(); this.cm = bp.getCurrentColorModel(); }
/** Converts a ShortProcessor to a ByteProcessor. */ ByteProcessor convertShortToByte() { int size = width*height; short[] pixels16 = (short[])ip.getPixels(); byte[] pixels8 = new byte[size]; if (doScaling) { int value, min=(int)ip.getMin(), max=(int)ip.getMax(); double scale = 256.0/(max-min+1); for (int i=0; i<size; i++) { value = (pixels16[i]&0xffff)-min; if (value<0) value = 0; value = (int)(value*scale+0.5); if (value>255) value = 255; pixels8[i] = (byte)value; } return new ByteProcessor(width, height, pixels8, ip.getCurrentColorModel()); } else { int value; for (int i=0; i<size; i++) { value = pixels16[i]&0xffff; if (value>255) value = 255; pixels8[i] = (byte)value; } return new ByteProcessor(width, height, pixels8, ip.getColorModel()); } }
/** Converts a ShortProcessor to a ByteProcessor. */ ByteProcessor convertShortToByte() { int size = width*height; short[] pixels16 = (short[])ip.getPixels(); byte[] pixels8 = new byte[size]; if (doScaling) { int value, min=(int)ip.getMin(), max=(int)ip.getMax(); double scale = 256.0/(max-min+1); for (int i=0; i<size; i++) { value = (pixels16[i]&0xffff)-min; if (value<0) value = 0; value = (int)(value*scale+0.5); if (value>255) value = 255; pixels8[i] = (byte)value; } return new ByteProcessor(width, height, pixels8, ip.getCurrentColorModel()); } else { int value; for (int i=0; i<size; i++) { value = pixels16[i]&0xffff; if (value>255) value = 255; pixels8[i] = (byte)value; } return new ByteProcessor(width, height, pixels8, ip.getColorModel()); } }
byte[] rLUT,gLUT,bLUT; int mapSize = 0; java.awt.image.ColorModel cm = imp.getProcessor().getCurrentColorModel(); if (cm instanceof IndexColorModel) { IndexColorModel m = (IndexColorModel)cm;
byte[] rLUT,gLUT,bLUT; int mapSize = 0; java.awt.image.ColorModel cm = imp.getProcessor().getCurrentColorModel(); if (cm instanceof IndexColorModel) { IndexColorModel m = (IndexColorModel)cm;
colorImage.getProcessor().getCurrentColorModel();
(IndexColorModel)ip.getCurrentColorModel(); int size = cm.getMapSize(); byte[] reds = new byte[size];
cm = ipSource.getColorModel(); } else { cm = ipSource.getCurrentColorModel();
cm = ipSource.getColorModel(); else cm = ipSource.getCurrentColorModel(); ipRamp = new FloatProcessor(width, height, pixels, cm);
cm = ipSource.getColorModel(); else cm = ipSource.getCurrentColorModel(); ipRamp = new FloatProcessor(width, height, pixels, cm);
maxThreshold = ip.getMaxThreshold(); boolean isThreshold = minThreshold != ImageProcessor.NO_THRESHOLD && ip.getCurrentColorModel() != ip.getColorModel(); //does not work??? if (not8Bits && minMaxChange && (!noReset || mode==OVER_UNDER)) { double max1 = ip.getMax();
maxThreshold = ip.getMaxThreshold(); boolean isThreshold = minThreshold != ImageProcessor.NO_THRESHOLD && ip.getCurrentColorModel() != ip.getColorModel(); //does not work??? if (not8Bits && minMaxChange && (!noReset || mode==OVER_UNDER)) { double max1 = ip.getMax();