/** Sets the display mode of composite color images, where 'mode' should be IJ.COMPOSITE, IJ.COLOR or IJ.GRAYSCALE. */ public void setDisplayMode(int mode) { if (this instanceof CompositeImage) { ((CompositeImage)this).setMode(mode); updateAndDraw(); } }
/** Sets the display mode of composite color images, where 'mode' should be IJ.COMPOSITE, IJ.COLOR or IJ.GRAYSCALE. */ public void setDisplayMode(int mode) { if (this instanceof CompositeImage) { ((CompositeImage)this).setMode(mode); updateAndDraw(); } }
/** * Sets the correct legacy ImageJ CompositeImage display mode based upon input * data values. */ private void setCompositeImageMode(final CompositeImage ci, final int composCount, final List<ColorTable> cTables) { if ((composCount > 1) || (cTables == null) || (cTables.size() == 0)) ci .setMode(CompositeImage.COMPOSITE); else { boolean allGrayTables = true; for (int i = 0; i < ci.getNChannels(); i++) { final ColorTable cTable = cTables.get(i); if ((allGrayTables) && (!ColorTables.isGrayColorTable(cTable))) { allGrayTables = false; } } if (allGrayTables) { ci.setMode(CompositeImage.GRAYSCALE); } else { ci.setMode(CompositeImage.COLOR); } } }
void setDisplayMode(ImagePlus imp, String mode) { mode = mode.toLowerCase(Locale.US); if (!imp.isComposite()) interp.error("Composite image required"); int m = -1; if (mode.equals("composite")) m = IJ.COMPOSITE; else if (mode.equals("color")) m = IJ.COLOR; else if (mode.startsWith("gray")) m = IJ.GRAYSCALE; if (m==-1) interp.error("Invalid mode"); ((CompositeImage)imp).setMode(m); imp.updateAndDraw(); }
void setDisplayMode(ImagePlus imp, String mode) { mode = mode.toLowerCase(Locale.US); if (!imp.isComposite()) interp.error("Composite image required"); int m = -1; if (mode.equals("composite")) m = IJ.COMPOSITE; else if (mode.equals("color")) m = IJ.COLOR; else if (mode.startsWith("gray")) m = IJ.GRAYSCALE; if (m==-1) interp.error("Invalid mode"); ((CompositeImage)imp).setMode(m); imp.updateAndDraw(); }
public void reset() { int nChannels = getNChannels(); if (nChannels>MAX_CHANNELS && getMode()==COMPOSITE) setMode(COLOR); setup(nChannels, getImageStack()); }
public void reset() { int nChannels = getNChannels(); if (nChannels>MAX_CHANNELS && getMode()==COMPOSITE) setMode(COLOR); setup(nChannels, getImageStack()); }
void toggleChannel(ImagePlus imp, int channel) { if (!imp.isComposite()) interp.error("Composite image required"); if (channel<1 || channel>imp.getNChannels()) interp.error("Invalid channel: "+channel); if (((CompositeImage)imp).getMode()!=IJ.COMPOSITE) ((CompositeImage)imp).setMode(IJ.COMPOSITE); boolean[] active = ((CompositeImage)imp).getActiveChannels(); active[channel-1] = active[channel-1]?false:true; imp.updateAndDraw(); Channels.updateChannels(); }
void toggleChannel(ImagePlus imp, int channel) { if (!imp.isComposite()) interp.error("Composite image required"); if (channel<1 || channel>imp.getNChannels()) interp.error("Invalid channel: "+channel); if (((CompositeImage)imp).getMode()!=IJ.COMPOSITE) ((CompositeImage)imp).setMode(IJ.COMPOSITE); boolean[] active = ((CompositeImage)imp).getActiveChannels(); active[channel-1] = active[channel-1]?false:true; imp.updateAndDraw(); Channels.updateChannels(); }
/** Copies the LUTs and display mode of 'imp' to this image. Does nothing if 'imp' is not a CompositeImage or 'imp' and this image do not have the same number of channels. */ public synchronized void copyLuts(ImagePlus imp) { int channels = getNChannels(); if (!imp.isComposite() || imp.getNChannels()!=channels) return; CompositeImage ci = (CompositeImage)imp; LUT[] luts = ci.getLuts(); if (luts!=null && luts.length==channels) { lut = luts; cip = null; } int mode2 = ci.getMode(); setMode(mode2); if (mode2==COMPOSITE) { boolean[] active2 = ci.getActiveChannels(); for (int i=0; i<MAX_CHANNELS; i++) active[i] = active2[i]; } if (ci.hasCustomLuts()) customLuts = true; }
/** Copies the LUTs and display mode of 'imp' to this image. Does nothing if 'imp' is not a CompositeImage or 'imp' and this image do not have the same number of channels. */ public synchronized void copyLuts(ImagePlus imp) { int channels = getNChannels(); if (!imp.isComposite() || imp.getNChannels()!=channels) return; CompositeImage ci = (CompositeImage)imp; LUT[] luts = ci.getLuts(); if (luts!=null && luts.length==channels) { lut = luts; cip = null; } int mode2 = ci.getMode(); setMode(mode2); if (mode2==COMPOSITE) { boolean[] active2 = ci.getActiveChannels(); for (int i=0; i<MAX_CHANNELS; i++) active[i] = active2[i]; } if (ci.hasCustomLuts()) customLuts = true; }
/** Converts an RGB image to an RGB (red, green and blue) stack. */ public void convertToRGBStack() { if (type!=ImagePlus.COLOR_RGB) throw new IllegalArgumentException("Image must be RGB"); //convert to RGB Stack ColorProcessor cp; if (imp.getType()==ImagePlus.COLOR_RGB) cp = (ColorProcessor)imp.getProcessor(); else cp = new ColorProcessor(imp.getImage()); int width = imp.getWidth(); int height = imp.getHeight(); byte[] R = new byte[width*height]; byte[] G = new byte[width*height]; byte[] B = new byte[width*height]; cp.getRGB(R, G, B); imp.trimProcessor(); // Create stack and select Red channel ColorModel cm = LookUpTable.createGrayscaleColorModel(false); ImageStack stack = new ImageStack(width, height, cm); stack.addSlice("Red", R); stack.addSlice("Green", G); stack.addSlice("Blue", B); imp.setStack(null, stack); imp.setDimensions(3, 1, 1); if (imp.isComposite()) ((CompositeImage)imp).setMode(IJ.GRAYSCALE); }
/** Converts an RGB image to an RGB (red, green and blue) stack. */ public void convertToRGBStack() { if (type!=ImagePlus.COLOR_RGB) throw new IllegalArgumentException("Image must be RGB"); //convert to RGB Stack ColorProcessor cp; if (imp.getType()==ImagePlus.COLOR_RGB) cp = (ColorProcessor)imp.getProcessor(); else cp = new ColorProcessor(imp.getImage()); int width = imp.getWidth(); int height = imp.getHeight(); byte[] R = new byte[width*height]; byte[] G = new byte[width*height]; byte[] B = new byte[width*height]; cp.getRGB(R, G, B); imp.trimProcessor(); // Create stack and select Red channel ColorModel cm = LookUpTable.createGrayscaleColorModel(false); ImageStack stack = new ImageStack(width, height, cm); stack.addSlice("Red", R); stack.addSlice("Green", G); stack.addSlice("Blue", B); imp.setStack(null, stack); imp.setDimensions(3, 1, 1); if (imp.isComposite()) ((CompositeImage)imp).setMode(IJ.GRAYSCALE); }
ci.setMode(CompositeImage.COMPOSITE); ci.updateAndDraw();
if (imp.isComposite() && (this instanceof CompositeImage)) { if (((CompositeImage)imp).getMode()!=((CompositeImage)this).getMode()) ((CompositeImage)this).setMode(((CompositeImage)imp).getMode()); luts = ((CompositeImage)imp).getLuts(); if (luts!=null) { ((CompositeImage)this).setLuts(luts); ((CompositeImage)this).setMode(((CompositeImage)imp).getMode()); updateAndRepaintWindow(); } else if (lut!=null) {
if (imp.isComposite() && (this instanceof CompositeImage)) { if (((CompositeImage)imp).getMode()!=((CompositeImage)this).getMode()) ((CompositeImage)this).setMode(((CompositeImage)imp).getMode()); luts = ((CompositeImage)imp).getLuts(); if (luts!=null) { ((CompositeImage)this).setLuts(luts); ((CompositeImage)this).setMode(((CompositeImage)imp).getMode()); updateAndRepaintWindow(); } else if (lut!=null) {
else if (imp.isComposite() && ((CompositeImage)imp).getMode()==IJ.GRAYSCALE) { CompositeImage cimp = (CompositeImage)imp; cimp.setMode(IJ.COLOR); int saveC = cimp.getChannel(); IndexColorModel cm = new IndexColorModel(8, 256, fi.reds, fi.greens, fi.blues);
else if (imp.isComposite() && ((CompositeImage)imp).getMode()==IJ.GRAYSCALE) { CompositeImage cimp = (CompositeImage)imp; cimp.setMode(IJ.COLOR); int saveC = cimp.getChannel(); IndexColorModel cm = new IndexColorModel(8, 256, fi.reds, fi.greens, fi.blues);