/** Returns the display mode (IJ.COMPOSITE, IJ.COLOR or IJ.GRAYSCALE) if this is a composite color image, or 0 if it not. */ public int getDisplayMode() { if (this instanceof CompositeImage) return ((CompositeImage)this).getMode(); else return 0; }
/** Returns the display mode (IJ.COMPOSITE, IJ.COLOR or IJ.GRAYSCALE) if this is a composite color image, or 0 if it not. */ public int getDisplayMode() { if (this instanceof CompositeImage) return ((CompositeImage)this).getMode(); else return 0; }
/** Returns the display mode (IJ.COMPOSITE, IJ.COLOR or IJ.GRAYSCALE) if this is a CompositeImage, otherwise returns -1. */ public int getCompositeMode() { if (isComposite()) return ((CompositeImage)this).getMode(); else return -1; }
/** Returns the display mode (IJ.COMPOSITE, IJ.COLOR or IJ.GRAYSCALE) if this is a CompositeImage, otherwise returns -1. */ public int getCompositeMode() { if (isComposite()) return ((CompositeImage)this).getMode(); else return -1; }
/** Draws the subtitle. */ public void drawInfo(Graphics g) { if (imp==null) return; if (textGap!=0) { Insets insets = super.getInsets(); if (imp.isComposite()) { CompositeImage ci = (CompositeImage)imp; if (ci.getMode()==IJ.COMPOSITE) { Color c = ci.getChannelColor(); if (Color.green.equals(c)) c = new Color(0,180,0); g.setColor(c); } } Java2.setAntialiasedText(g, true); g.drawString(createSubtitle(), insets.left+5, insets.top+TEXT_GAP); } }
/** Draws the subtitle. */ public void drawInfo(Graphics g) { if (imp==null) return; if (textGap!=0) { Insets insets = super.getInsets(); if (imp.isComposite()) { CompositeImage ci = (CompositeImage)imp; if (ci.getMode()==IJ.COMPOSITE) { Color c = ci.getChannelColor(); if (Color.green.equals(c)) c = new Color(0,180,0); g.setColor(c); } } Java2.setAntialiasedText(g, true); g.drawString(createSubtitle(), insets.left+5, insets.top+TEXT_GAP); } }
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()); }
/** Adds a checkbox labelled "Preview" for "automatic" preview. * The reference to this checkbox can be retrieved by getPreviewCheckbox() * and it provides the additional method previewRunning for optical * feedback while preview is prepared. * PlugInFilters can have their "run" method automatically called for * preview under the following conditions: * - the PlugInFilter must pass a reference to itself (i.e., "this") as an * argument to the AddPreviewCheckbox * - it must implement the DialogListener interface and set the filter * parameters in the dialogItemChanged method. * - it must have DIALOG and PREVIEW set in its flags. * A previewCheckbox is always off when the filter is started and does not get * recorded by the Macro Recorder. * * @param pfr A reference to the PlugInFilterRunner calling the PlugInFilter * if automatic preview is desired, null otherwise. */ public void addPreviewCheckbox(PlugInFilterRunner pfr) { if (previewCheckbox != null) return; ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null && imp.isComposite() && ((CompositeImage)imp).getMode()==IJ.COMPOSITE) return; this.pfr = pfr; addCheckbox(previewLabel, false, true); }
/** * Sets the {@link Dataset}'s number of composite channels to display * simultaneously based on an input {@link ImagePlus}'s makeup. */ @Override public void updateDataset(final Dataset ds, final ImagePlus imp) { if ((imp instanceof CompositeImage) && (((CompositeImage) imp).getMode() == CompositeImage.COMPOSITE)) { ds.setCompositeChannelCount(imp.getNChannels()); } else if (imp.getType() == ImagePlus.COLOR_RGB && imp.getNChannels() == 1) { ds.setCompositeChannelCount(3); } else ds.setCompositeChannelCount(1); }
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; }
public void update() { CompositeImage ci = getImage(); if (ci==null || checkbox==null) return; int n = checkbox.length; int nChannels = ci.getNChannels(); if (nChannels!=n && nChannels<=CompositeImage.MAX_CHANNELS) { instance = null; location = getLocation(); close(); new Channels(); return; } boolean[] active = ci.getActiveChannels(); for (int i=0; i<checkbox.length; i++) checkbox[i].setState(active[i]); int index = 0; switch (ci.getMode()) { case IJ.COMPOSITE: index=0; break; case IJ.COLOR: index=1; break; case IJ.GRAYSCALE: index=2; break; } choice.select(index); }
public void update() { CompositeImage ci = getImage(); if (ci==null || checkbox==null) return; int n = checkbox.length; int nChannels = ci.getNChannels(); if (nChannels!=n && nChannels<=CompositeImage.MAX_CHANNELS) { instance = null; location = getLocation(); close(); new Channels(); return; } boolean[] active = ci.getActiveChannels(); for (int i=0; i<checkbox.length; i++) checkbox[i].setState(active[i]); int index = 0; switch (ci.getMode()) { case IJ.COMPOSITE: index=0; break; case IJ.COLOR: index=1; break; case IJ.GRAYSCALE: index=2; break; } choice.select(index); }
public ImageProcessor straighten(ImagePlus imp, Roi roi, int width) { ImageProcessor ip2; if (imp.getBitDepth()==24 && roi.getType()!=Roi.LINE) ip2 = straightenRGB(imp, width); else if (imp.isComposite() && ((CompositeImage)imp).getMode()==IJ.COMPOSITE) { if (roi.getType()==Roi.LINE) ip2 = rotateCompositeLine(imp, width); else ip2 = straightenComposite(imp, width); } else if (roi.getType()==Roi.LINE) ip2 = rotateLine(imp, width); else ip2 = straightenLine(imp, width); return ip2; }
public ImageProcessor straighten(ImagePlus imp, Roi roi, int width) { ImageProcessor ip2; if (imp.getBitDepth()==24 && roi.getType()!=Roi.LINE) ip2 = straightenRGB(imp, width); else if (imp.isComposite() && ((CompositeImage)imp).getMode()==IJ.COMPOSITE) { if (roi.getType()==Roi.LINE) ip2 = rotateCompositeLine(imp, width); else ip2 = straightenComposite(imp, width); } else if (roi.getType()==Roi.LINE) ip2 = rotateLine(imp, width); else ip2 = straightenLine(imp, width); return ip2; }
private void setPosition(ImagePlus imp, Roi roi) { boolean setPos = defaultRoi.getPosition()!=0; int stackSize = imp.getStackSize(); if (setPos && stackSize>1) { if (imp.isHyperStack()||imp.isComposite()) { boolean compositeMode = imp.isComposite() && ((CompositeImage)imp).getMode()==IJ.COMPOSITE; int channel = !compositeMode||imp.getNChannels()==stackSize?imp.getChannel():0; if (imp.getNSlices()>1) roi.setPosition(channel, imp.getSlice(), 0); else if (imp.getNFrames()>1) roi.setPosition(channel, 0, imp.getFrame()); } else roi.setPosition(imp.getCurrentSlice()); } }
private void setPosition(ImagePlus imp, Roi roi) { boolean setPos = defaultRoi.getPosition()!=0; int stackSize = imp.getStackSize(); if (setPos && stackSize>1) { if (imp.isHyperStack()||imp.isComposite()) { boolean compositeMode = imp.isComposite() && ((CompositeImage)imp).getMode()==IJ.COMPOSITE; int channel = !compositeMode||imp.getNChannels()==stackSize?imp.getChannel():0; if (imp.getNSlices()>1) roi.setPosition(channel, imp.getSlice(), 0); else if (imp.getNFrames()>1) roi.setPosition(channel, 0, imp.getFrame()); } else roi.setPosition(imp.getCurrentSlice()); } }
void swapStackImages(ImagePlus imp) { int n1 = (int)getFirstArg(); int n2 = (int)getLastArg(); ImageStack stack = imp.getStack(); int size = stack.getSize(); if (n1<1||n1>size||n2<1||n2>size) interp.error("Argument out of range"); Object pixels = stack.getPixels(n1); String label = stack.getSliceLabel(n1); stack.setPixels(stack.getPixels(n2), n1); stack.setSliceLabel(stack.getSliceLabel(n2), n1); stack.setPixels(pixels, n2); stack.setSliceLabel(label, n2); int current = imp.getCurrentSlice(); if (imp.isComposite()) { CompositeImage ci = (CompositeImage)imp; if (ci.getMode()==IJ.COMPOSITE) { ci.reset(); imp.updateAndDraw(); imp.repaintWindow(); return; } } if (n1==current || n2==current) imp.setStack(null, stack); }