public static boolean okForFits(ImagePlus imp) { if (imp.getBitDepth()==24) { IJ.error("FITS Writer", "Grayscale image required"); return false; } else return true; }
/** Constructs a new Calibration object using the default values. */ public Calibration(ImagePlus imp) { if (imp!=null) { bitDepth = imp.getBitDepth(); if (bitDepth!=UNKNOWN) invertedLut=imp.isInvertedLut(); } }
private void setImage(ImagePlus imp) { this.binaryImage = imp; ImageStatistics stats = imp.getStatistics(); boolean notBinary = (stats.histogram[0] + stats.histogram[255]) != stats.pixelCount; boolean toManyChannels = (imp.getNChannels()>1); boolean wrongBitDepth = (imp.getBitDepth()!=8); if (notBinary | toManyChannels | wrongBitDepth) { throw new java.lang.IllegalArgumentException("Wrong Image Format. IJ Blob only supports 8-bit, single-channel binary images"); } }
public int setup(String arg, ImagePlus imp) { if (imp==null) return DONE; isRGB = imp.getBitDepth()==24; if (!showDialog()) return DONE; return IJ.setupDialog(imp, DOES_ALL-DOES_32+SUPPORTS_MASKING); }
/** Saves grayscale images in PGM (portable graymap) format and RGB images in PPM (portable pixmap) format, using a save file dialog. Returns false if the user selects cancel. */ public boolean saveAsPgm() { String extension = imp.getBitDepth()==24?".pnm":".pgm"; String path = getPath("PGM", extension); if (path==null) return false; else return saveAsPgm(path); }
public void writeImage(ImagePlus imp, String path, int transparentIndex) throws Exception { if (imp.getStackSize()==4 && imp.getBitDepth()==8 && "alpha".equalsIgnoreCase(imp.getStack().getSliceLabel(4))) writeFourChannelsWithAlpha(imp, path); else if (transparentIndex>=0 && transparentIndex<=255 && imp.getBitDepth()==8) writeImageWithTransparency(imp, path, transparentIndex); else if (imp.getOverlay()!=null && !imp.getHideOverlay()) ImageIO.write(imp.flatten().getBufferedImage(), "png", new File(path)); else if (imp.getBitDepth()==16 && !imp.isComposite() && imp.getProcessor().isDefaultLut()) write16gs(imp, path); else ImageIO.write(imp.getBufferedImage(), "png", new File(path)); }
private LUT[] getLuts() { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null || imp.getBitDepth()!=16 || !imp.isComposite()) return null; return ((CompositeImage)imp).getLuts(); }
/** Converts the current image from RGB to CIE L*a*b* and stores the results * in the same RGB image R=L*, G=a*, B=b*. Values are therfore offset and rescaled. */ public static void RGBtoLab() { ImagePlus imp = IJ.getImage(); if (imp.getBitDepth()==24) imp.setProcessor(RGBtoLab(imp.getProcessor())); }
/** Converts the current image from RGB to YUV and stores * the results in the same RGB image R=Y, G=U, B=V. * Author: Gabriel Landini, G.Landini@bham.ac.uk */ public static void RGBtoYUV() { ImagePlus imp = IJ.getImage(); if (imp.getBitDepth()==24) { RGBtoYUV(imp.getProcessor()); imp.updateAndDraw(); } }
/** Converts the current image from RGB to YUV and stores * the results in the same RGB image R=Y, G=U, B=V. * Author: Gabriel Landini, G.Landini@bham.ac.uk */ public static void RGBtoYUV() { ImagePlus imp = IJ.getImage(); if (imp.getBitDepth()==24) { RGBtoYUV(imp.getProcessor()); imp.updateAndDraw(); } }
/** Converts the current image from RGB to CIE L*a*b* and stores the results * in the same RGB image R=L*, G=a*, B=b*. Values are therfore offset and rescaled. */ public static void RGBtoLab() { ImagePlus imp = IJ.getImage(); if (imp.getBitDepth()==24) imp.setProcessor(RGBtoLab(imp.getProcessor())); }
/** Creates a StackStatistics object from a stack, using the specified histogram bin count and x-axis range (pixel value tange). */ public StackStatistics(ImagePlus imp, int nBins, double xMin, double xMax) { int bits = imp.getBitDepth(); stackStatistics = true; if ((bits==8||bits==24) && nBins==256 && xMin==0.0 && xMax==256.0) sum8BitHistograms(imp); else if (bits==16 && nBins==256 && xMin==0.0 && xMax==0.0 && !imp.getCalibration().calibrated()) sum16BitHistograms(imp); else doCalculations(imp, nBins, xMin, xMax); }
public void windowActivated(WindowEvent e) { super.windowActivated(e); if (IJ.isMacro()) { // do nothing if macro and RGB image ImagePlus imp2 = WindowManager.getCurrentImage(); if (imp2!=null && imp2.getBitDepth()==24) { return; } } previousImageID = 0; // user may have modified image setup(); WindowManager.setWindow(this); }
public void windowActivated(WindowEvent e) { if (IJ.debugMode) IJ.log("ColorThresholder.windowActivated "); ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null || imp.getBitDepth()!=24) { IJ.beep(); IJ.showStatus("No RGB image"); } else { setup(imp); //reset(imp); filteredB.setEnabled(true); } }
public ImageProcessor rotateLine(ImagePlus imp, int width) { Roi roi = imp.getRoi(); if (roi==null || roi.getType()!=Roi.LINE) throw new IllegalArgumentException("Straight line selection expected"); Polygon p = ((Line)roi).getPoints(); imp.setRoi(new PolygonRoi(p.xpoints, p.ypoints, 2, Roi.POLYLINE)); ImageProcessor ip2 = imp.getBitDepth()==24?straightenRGB(imp, width):straightenLine(imp, width); imp.setRoi(roi); return ip2; }
public void windowActivated(WindowEvent e) { if (IJ.debugMode) IJ.log("ColorThresholder.windowActivated "); ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null || imp.getBitDepth()!=24) { IJ.beep(); IJ.showStatus("No RGB image"); } else { setup(imp); //reset(imp); filteredB.setEnabled(true); } }
ImageStatistics getRedirectStats(int measurements, Roi roi) { ImagePlus redirectImp = getRedirectImageOrStack(imp); if (redirectImp==null) return null; ImageProcessor ip = redirectImp.getProcessor(); if (imp.getTitle().equals("mask") && imp.getBitDepth()==8) { ip.setMask(imp.getProcessor()); ip.setRoi(0, 0, imp.getWidth(), imp.getHeight()); } else ip.setRoi(roi); return ImageStatistics.getStatistics(ip, measurements, redirectImp.getCalibration()); }
/** Converts this ImagePlus to RGB. */ public void convertToRGB() { if (imp.getBitDepth()==24) return; if (imp.getStackSize()>1) { new StackConverter(imp).convertToRGB(); return; } ImageProcessor ip = imp.getProcessor(); imp.setProcessor(null, ip.convertToRGB()); imp.setCalibration(imp.getCalibration()); //update calibration }
/** Converts this ImagePlus to RGB. */ public void convertToRGB() { if (imp.getBitDepth()==24) return; if (imp.getStackSize()>1) { new StackConverter(imp).convertToRGB(); return; } ImageProcessor ip = imp.getProcessor(); imp.setProcessor(null, ip.convertToRGB()); imp.setCalibration(imp.getCalibration()); //update calibration }
void setMinAndMax() { double min = getFirstArg(); double max = getNextArg(); int channels = 7; if (interp.nextToken()==',') { channels = (int)getLastArg(); if (getImage().getBitDepth()!=24) interp.error("RGB image required"); } else interp.getRightParen(); IJ.setMinAndMax(min, max, channels); resetImage(); }