protected static LUT createLUT() { final byte[] red = new byte[256]; final byte[] green = new byte[256]; final byte[] blue = new byte[256]; for (int i = 0; i < 128; i++) { red[i] = (byte)((128 - i) * (128 - i) * 127 / 128 / 128); green[i] = (byte)((128 - i) * 220 / 128); if (i < 64) { blue[i] = (byte)(220 + i * (150 - 220) / 64); } else { blue[i] = (byte)((128 - i) * 150 / 64); } } for (int i = 128; i < 192; i++) { red[i] = green[i] = blue[i] = (byte)((i - 128) * 255 / 64); } for (int i = 192; i < 256; i++) { red[i] = (byte)(255 + (i - 192) * (127 - 255) / 64); green[i] = blue[i] = (byte)(255 + (i - 192) * (220 - 255) / 64); } return new LUT(red, green, blue); }
public LUT createLutFromColor(Color color) { return LUT.createLutFromColor(color); }
public LUT createInvertedLut() { int mapSize = getMapSize(); byte[] reds = new byte[mapSize]; byte[] greens = new byte[mapSize]; byte[] blues = new byte[mapSize]; byte[] reds2 = new byte[mapSize]; byte[] greens2 = new byte[mapSize]; byte[] blues2 = new byte[mapSize]; getReds(reds); getGreens(greens); getBlues(blues); for (int i=0; i<mapSize; i++) { reds2[i] = (byte)(reds[mapSize-i-1]&255); greens2[i] = (byte)(greens[mapSize-i-1]&255); blues2[i] = (byte)(blues[mapSize-i-1]&255); } return new LUT(8, mapSize, reds2, greens2, blues2); }
public byte[] getBytes() { int size = getMapSize(); if (size!=256) return null; byte[] bytes = new byte[256*3]; for (int i=0; i<256; i++) bytes[i] = (byte)getRed(i); for (int i=0; i<256; i++) bytes[256+i] = (byte)getGreen(i); for (int i=0; i<256; i++) bytes[512+i] = (byte)getBlue(i); return bytes; }
LUT lut = null; if (c<colors.length && colors[c]!=null && (ignoreLuts||allGrayLuts)) { lut = LUT.createLutFromColor(colors[c]); lut.min = ip.getMin(); lut.max = ip.getMax(); } else lut = new LUT(cm, ip.getMin(), ip.getMax()); ((CompositeImage)imp2).setChannelLut(lut, c+1);
r = 2 * norm - 1; channeLuts[i] = LUT.createLutFromColor(new Color(r, g, b)); colorizationLut.getComponents((int)(((float) i / zSlices) * 255f), rgb, 0); channeLuts[i] = LUT.createLutFromColor(new Color(rgb[0], rgb[1], rgb[2]));
LUT lut = null; if (c<colors.length && colors[c]!=null && (ignoreLuts||allGrayLuts)) { lut = LUT.createLutFromColor(colors[c]); lut.min = ip.getMin(); lut.max = ip.getMax(); } else lut = new LUT(cm, ip.getMin(), ip.getMax()); ((CompositeImage)imp2).setChannelLut(lut, c+1);
public byte[] getBytes() { int size = getMapSize(); if (size!=256) return null; byte[] bytes = new byte[256*3]; for (int i=0; i<256; i++) bytes[i] = (byte)getRed(i); for (int i=0; i<256; i++) bytes[256+i] = (byte)getGreen(i); for (int i=0; i<256; i++) bytes[512+i] = (byte)getBlue(i); return bytes; }
/** Creates a color LUT from a Color. */ public static LUT createLutFromColor(Color color) { byte[] rLut = new byte[256]; byte[] gLut = new byte[256]; byte[] bLut = new byte[256]; int red = color.getRed(); int green = color.getGreen(); int blue = color.getBlue(); double rIncr = ((double)red)/255d; double gIncr = ((double)green)/255d; double bIncr = ((double)blue)/255d; for (int i=0; i<256; ++i) { rLut[i] = (byte)(i*rIncr); gLut[i] = (byte)(i*gIncr); bLut[i] = (byte)(i*bIncr); } return new LUT(rLut, gLut, bLut); }
public LUT createInvertedLut() { int mapSize = getMapSize(); byte[] reds = new byte[mapSize]; byte[] greens = new byte[mapSize]; byte[] blues = new byte[mapSize]; byte[] reds2 = new byte[mapSize]; byte[] greens2 = new byte[mapSize]; byte[] blues2 = new byte[mapSize]; getReds(reds); getGreens(greens); getBlues(blues); for (int i=0; i<mapSize; i++) { reds2[i] = (byte)(reds[mapSize-i-1]&255); greens2[i] = (byte)(greens[mapSize-i-1]&255); blues2[i] = (byte)(blues[mapSize-i-1]&255); } return new LUT(8, mapSize, reds2, greens2, blues2); }
/** tests that the first and last entries of a lut match expected values */ private void lutTest(CompositeImage ci, int channel, int minR, int minG, int minB, int maxR, int maxG, int maxB) { // channel is 0-based LUT lut = ci.getChannelLut(channel+1); // IJ is 1-based byte[] reds = new byte[256]; byte[] blues = new byte[256]; byte[] greens = new byte[256]; lut.getReds(reds); lut.getGreens(greens); lut.getBlues(blues); assertEquals((byte)minR,reds[0]); assertEquals((byte)maxR,reds[255]); assertEquals((byte)minG,greens[0]); assertEquals((byte)maxG,greens[255]); assertEquals((byte)minB,blues[0]); assertEquals((byte)maxB,blues[255]); }
public LUT createLutFromColor(Color color) { return LUT.createLutFromColor(color); }
protected void transferChannelSettings( final CompositeImage ci, final SetupAssignments setupAssignments, final VisibilityAndGrouping visibility ) { final int nChannels = ci.getNChannels(); final int mode = ci.getCompositeMode(); final boolean transferColor = mode == IJ.COMPOSITE || mode == IJ.COLOR; for ( int c = 0; c < nChannels; ++c ) { final LUT lut = ci.getChannelLut( c + 1 ); final ConverterSetup setup = setupAssignments.getConverterSetups().get( c ); if ( transferColor ) setup.setColor( new ARGBType( lut.getRGB( 255 ) ) ); setup.setDisplayRange( lut.min, lut.max ); } if ( mode == IJ.COMPOSITE ) { final boolean[] activeChannels = ci.getActiveChannels(); visibility.setDisplayMode( DisplayMode.FUSED ); for ( int i = 0; i < activeChannels.length; ++i ) visibility.setSourceActive( i, activeChannels[ i ] ); } else visibility.setDisplayMode( DisplayMode.SINGLE ); visibility.setCurrentSource( ci.getChannel() - 1 ); }
private LUT makeLUT(Color color) { final int red = color.getRed(); final int green = color.getGreen(); final int blue = color.getBlue(); final int lutLength = 256; final int lutDivisor = lutLength - 1; byte[] r = new byte[lutLength]; byte[] g = new byte[lutLength]; byte[] b = new byte[lutLength]; for (int i=0; i<lutLength; i++) { r[i] = (byte) (i * red / lutDivisor); g[i] = (byte) (i * green / lutDivisor); b[i] = (byte) (i * blue / lutDivisor); } LUT lut = new LUT(r, g, b); return lut; }
public IndexColorModel getColorModel() { if (cm==null) { byte[] reds=new byte[256]; getReds(reds); byte[] greens=new byte[256]; getGreens(greens); byte[] blues=new byte[256]; getBlues(blues); cm = new IndexColorModel(8, getMapSize(), reds, greens, blues); } return cm; }
private void imagePlusLutTest(ImagePlus imp, boolean indexed, boolean falseColor, Color color) { // When numCh < 2 or numCh > 7 the setColorMode() code for Composite and Colorize cannot create a CompositeImage. // Therefore it creates a one channel ImagePlus with a LUT that only ramps the red channel. Test this to be // the case. assertFalse(imp instanceof CompositeImage); if (indexed) { fail("not yet supporting indexed"); } LUT lut = getColorTable(imp,0); byte[] data = new byte[256]; if (color.getRed() > 0) { lut.getReds(data); ascendingValuesTest(data,256); } if (color.getGreen() > 0) { lut.getGreens(data); ascendingValuesTest(data,256); } if (color.getBlue() > 0) { lut.getBlues(data); ascendingValuesTest(data,256); } }