public void saveDisplayRangesAndLuts(ImagePlus imp, FileInfo fi) { CompositeImage ci = (CompositeImage)imp; int channels = imp.getNChannels(); fi.displayRanges = new double[channels*2]; for (int i=1; i<=channels; i++) { LUT lut = ci.getChannelLut(i); fi.displayRanges[(i-1)*2] = lut.min; fi.displayRanges[(i-1)*2+1] = lut.max; } if (ci.hasCustomLuts()) { fi.channelLuts = new byte[channels][]; for (int i=0; i<channels; i++) { LUT lut = ci.getChannelLut(i+1); byte[] bytes = lut.getBytes(); if (bytes==null) {fi.channelLuts=null; break;} fi.channelLuts[i] = bytes; } } }
public void saveDisplayRangesAndLuts(ImagePlus imp, FileInfo fi) { CompositeImage ci = (CompositeImage)imp; int channels = imp.getNChannels(); fi.displayRanges = new double[channels*2]; for (int i=1; i<=channels; i++) { LUT lut = ci.getChannelLut(i); fi.displayRanges[(i-1)*2] = lut.min; fi.displayRanges[(i-1)*2+1] = lut.max; } if (ci.hasCustomLuts()) { fi.channelLuts = new byte[channels][]; for (int i=0; i<channels; i++) { LUT lut = ci.getChannelLut(i+1); byte[] bytes = lut.getBytes(); if (bytes==null) {fi.channelLuts=null; break;} fi.channelLuts[i] = bytes; } } }
/** Tester for composite (multi-channel) images. */ private void test(int pixelType, boolean autoscale, boolean crop, double calib, double min1, double max1, double min2, double max2, double min3, double max3) { final ImagePlus imp = setup(pixelType, autoscale, crop, calib, 3); final CompositeImage ci = (CompositeImage) imp; final LUT lut1 = ci.getChannelLut(1); final LUT lut2 = ci.getChannelLut(2); final LUT lut3 = ci.getChannelLut(3); assertEquals(min1 - calib, lut1.min, 0.0); assertEquals(max1 - calib, lut1.max, 0.0); assertEquals(min2 - calib, lut2.min, 0.0); assertEquals(max2 - calib, lut2.max, 0.0); assertEquals(min3 - calib, lut3.min, 0.0); assertEquals(max3 - calib, lut3.max, 0.0); }
ColorModel colormodel(final int c) { if (imagetype == IMAGE5D) return I5DResource.processor(image,c).getColorModel(); else if (image.isComposite()) return ((CompositeImage)image).getChannelLut(c); else return image.getProcessor().getColorModel(); }
/** 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]); }
double minshown(final int c) { if (imagetype == IMAGE5D) return I5DResource.processor(image,c).getMin(); else if (image.isComposite()) return ((CompositeImage)image).getChannelLut(c).min; else return image.getProcessor().getMin(); }
double maxshown(final int c) { if (imagetype == IMAGE5D) return I5DResource.processor(image,c).getMax(); else if (image.isComposite()) return ((CompositeImage)image).getChannelLut(c).max; else return image.getProcessor().getMax(); }
private static void minmax(final ImagePlus imp, final double min, final double max) { switch (type(imp)) { case IMAGE5D: { I5DResource.minmax(imp,min,max); break; } case COMPOSITEIMAGE: { final CompositeImage ci = (CompositeImage)imp; final int nc = ci.getNChannels(); for (int c=1; c<=nc; ++c) { final LUT lut = ci.getChannelLut(c); lut.min = min; lut.max = max; } break; } case HYPERSTACK: case IMAGESTACK: case SINGLEIMAGE: { imp.setDisplayRange(min,max); break; } } }
public void resetDisplayRange() { if (getType()==GRAY16 && getDefault16bitRange()!=0) { int defaultRange = getDefault16bitRange(); for (int i=1; i<=getNChannels(); i++) { LUT lut = getChannelLut(i); lut.min = 0; lut.max = Math.pow(2,defaultRange)-1; if (getWindow()!=null) setChannelLut(lut, i); } } else { ip.resetMinAndMax(); int c = getChannelIndex(); lut[c].min = ip.getMin(); lut[c].max = ip.getMax(); } }
public void resetDisplayRange() { if (getType()==GRAY16 && getDefault16bitRange()!=0) { int defaultRange = getDefault16bitRange(); for (int i=1; i<=getNChannels(); i++) { LUT lut = getChannelLut(i); lut.min = 0; lut.max = Math.pow(2,defaultRange)-1; if (getWindow()!=null) setChannelLut(lut, i); } } else { ip.resetMinAndMax(); int c = getChannelIndex(); lut[c].min = ip.getMin(); lut[c].max = ip.getMax(); } }
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 ); }
/** gets the color table from any kind of ImagePlus (composite or not) - not for general use */ private LUT getColorTable(ImagePlus imp, int channel) { if (imp instanceof CompositeImage) return ((CompositeImage)imp).getChannelLut(channel+1); // else a regular ImagePlus IndexColorModel icm = (IndexColorModel)imp.getProcessor().getColorModel(); // TODO - maybe I can cast from IndexColorModel to LUT here - depends what IJ did. // otherwise make a LUT byte[] reds = new byte[256], greens = new byte[256], blues = new byte[256]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); return new LUT(reds,greens,blues); }
void invertLut() { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) {IJ.noImage(); return;} if (imp.getType()==ImagePlus.COLOR_RGB) {IJ.error("RGB images do not use LUTs"); return;} if (imp.isComposite()) { CompositeImage ci = (CompositeImage)imp; LUT lut = ci.getChannelLut(); if (lut!=null) ci.setChannelLut(lut.createInvertedLut()); } else { ImageProcessor ip = imp.getProcessor(); ip.invertLut(); if (imp.getStackSize()>1) imp.getStack().setColorModel(ip.getColorModel()); } imp.updateAndRepaintWindow(); }
void invertLut() { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) {IJ.noImage(); return;} if (imp.getType()==ImagePlus.COLOR_RGB) {IJ.error("RGB images do not use LUTs"); return;} if (imp.isComposite()) { CompositeImage ci = (CompositeImage)imp; LUT lut = ci.getChannelLut(); if (lut!=null) ci.setChannelLut(lut.createInvertedLut()); } else { ImageProcessor ip = imp.getProcessor(); ip.invertLut(); if (imp.getStackSize()>1) imp.getStack().setColorModel(ip.getColorModel()); } imp.updateAndRepaintWindow(); }
LUT lut = ((CompositeImage)imp).getChannelLut(); imp2.getProcessor().setColorModel(lut);
void getLut() { Variable reds = getFirstArrayVariable(); Variable greens = getNextArrayVariable(); Variable blues = getLastArrayVariable(); ImagePlus imp = getImage(); IndexColorModel cm = null; if (imp.isComposite()) cm = ((CompositeImage)imp).getChannelLut(); else { ImageProcessor ip = imp.getProcessor(); if (ip instanceof ColorProcessor) interp.error("Non-RGB image expected"); cm = (IndexColorModel)ip.getColorModel(); } int mapSize = cm.getMapSize(); byte[] rLUT = new byte[mapSize]; byte[] gLUT = new byte[mapSize]; byte[] bLUT = new byte[mapSize]; cm.getReds(rLUT); cm.getGreens(gLUT); cm.getBlues(bLUT); reds.setArray(new Variable(rLUT).getArray()); greens.setArray(new Variable(gLUT).getArray()); blues.setArray(new Variable(bLUT).getArray()); }
final int nc = newcimp.getNChannels(); for (int c=1; c<=nc; ++c) { final LUT lut = newcimp.getChannelLut(c); lut.min = min; lut.max = max;
void getLut() { Variable reds = getFirstArrayVariable(); Variable greens = getNextArrayVariable(); Variable blues = getLastArrayVariable(); ImagePlus imp = getImage(); IndexColorModel cm = null; if (imp.isComposite()) cm = ((CompositeImage)imp).getChannelLut(); else { ImageProcessor ip = imp.getProcessor(); if (ip instanceof ColorProcessor) interp.error("Non-RGB image expected"); cm = (IndexColorModel)ip.getColorModel(); } int mapSize = cm.getMapSize(); byte[] rLUT = new byte[mapSize]; byte[] gLUT = new byte[mapSize]; byte[] bLUT = new byte[mapSize]; cm.getReds(rLUT); cm.getGreens(gLUT); cm.getBlues(bLUT); reds.setArray(new Variable(rLUT).getArray()); greens.setArray(new Variable(gLUT).getArray()); blues.setArray(new Variable(bLUT).getArray()); }
max = stats.max; } else cm = ((CompositeImage)imp).getChannelLut(); } else if (ipSource.getMinThreshold()==ImageProcessor.NO_THRESHOLD) cm = ipSource.getColorModel();
for (int c=1; c<=channels; c++) { if (channels==1) c = c1; LUT lut = imp.isComposite()?((CompositeImage)imp).getChannelLut():imp.getProcessor().getLut(); imp.setPositionWithoutUpdate(c, 1, 1); ImageProcessor ip = imp.getProcessor();