public void closeAndReset( ) { if( ! single_pane ) { zy.close(); xz.close(); } if( original_xy_canvas != null && xy != null && xy.getImage() != null ) xy_window = new StackWindow( xy, original_xy_canvas ); }
/** Returns a copy of this image as an 8-bit or RGB BufferedImage. * @see ij.process.ShortProcessor#get16BitBufferedImage */ public BufferedImage getBufferedImage() { if (isComposite()) return (new ColorProcessor(getImage())).getBufferedImage(); else return ip.getBufferedImage(); }
/** Returns a copy of this image as an 8-bit or RGB BufferedImage. * @see ij.process.ShortProcessor#get16BitBufferedImage */ public BufferedImage getBufferedImage() { if (isComposite()) return (new ColorProcessor(getImage())).getBufferedImage(); else return ip.getBufferedImage(); }
protected void addImageToList(ImagePlus imp, String name) { java.awt.Image awtImage = imp.getImage(); try { com.itextpdf.text.Image pdfImage = com.itextpdf.text.Image.getInstance(awtImage, null); pdfImage.setAlt(name); // iText-1.3 setMarkupAttribute("name", name); listOfPDFImages.add(pdfImage); } catch (BadElementException e) { IJ.log("Could not convert image to correct format for PDF generation"); IJ.handleException(e); } catch (IOException e) { IJ.log("Could not convert image to correct format for PDF generation"); IJ.handleException(e); } }
protected void setSurfacePlotTextureImage(ImagePlus imp){ widthTex = imp.getWidth(); heightTex = imp.getHeight(); pixelsTexColor = new int[widthTex*heightTex]; image = imp.getImage(); PixelGrabber pg = new PixelGrabber(image, 0, 0, widthTex, heightTex, pixelsTexColor, 0, widthTex); try { pg.grabPixels(); } catch (InterruptedException ex) { IJ.error("error grabbing pixels"); pixelsTexColor = null; } }
/** Converts an RGB image to a HSB (hue, saturation and brightness) stack. */ public void convertToHSB() { if (type!=ImagePlus.COLOR_RGB) throw new IllegalArgumentException("Image must be RGB");; ColorProcessor cp; if (imp.getType()==ImagePlus.COLOR_RGB) cp = (ColorProcessor)imp.getProcessor(); else cp = new ColorProcessor(imp.getImage()); ImageStack stack = cp.getHSBStack(); imp.trimProcessor(); imp.setStack(null, stack); imp.setDimensions(3, 1, 1); }
/** Converts an RGB image to a HSB (hue, saturation and brightness) stack. */ public void convertToHSB() { if (type!=ImagePlus.COLOR_RGB) throw new IllegalArgumentException("Image must be RGB");; ColorProcessor cp; if (imp.getType()==ImagePlus.COLOR_RGB) cp = (ColorProcessor)imp.getProcessor(); else cp = new ColorProcessor(imp.getImage()); ImageStack stack = cp.getHSBStack(); imp.trimProcessor(); imp.setStack(null, stack); imp.setDimensions(3, 1, 1); }
ImageProcessor rotateCompositeLine(ImagePlus imp, int width) { Image img = imp.getImage(); ImagePlus imp2 = new ImagePlus("temp", new ColorProcessor(img)); imp2.setRoi(imp.getRoi()); ImageProcessor ip2 = rotateLine(imp2, width); return ip2; }
ImageProcessor rotateCompositeLine(ImagePlus imp, int width) { Image img = imp.getImage(); ImagePlus imp2 = new ImagePlus("temp", new ColorProcessor(img)); imp2.setRoi(imp.getRoi()); ImageProcessor ip2 = rotateLine(imp2, width); return ip2; }
ImageProcessor straightenComposite(ImagePlus imp, int width) { Image img = imp.getImage(); ImagePlus imp2 = new ImagePlus("temp", new ColorProcessor(img)); imp2.setRoi(imp.getRoi()); ImageProcessor ip2 = straightenRGB(imp2, width); imp.setRoi(imp2.getRoi()); return ip2; }
private void doGraph() { if (flow instanceof FlowJFlow && trueFlow instanceof FlowJFlow) { ImagePlus imp = new ImagePlus("True-Estimate "+description, GUI.createBlankImage(300,300)); ImageWindow imw = new ImageWindow(imp); imp.show(); Image img = imp.getImage(); FlowJError.map(img.getGraphics(), 300, 300, flow, trueFlow); } else IJ.error("flow or true flow not known"); } /**
ImageProcessor straightenComposite(ImagePlus imp, int width) { Image img = imp.getImage(); ImagePlus imp2 = new ImagePlus("temp", new ColorProcessor(img)); imp2.setRoi(imp.getRoi()); ImageProcessor ip2 = straightenRGB(imp2, width); imp.setRoi(imp2.getRoi()); return ip2; }
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { if (!isDataFlavorSupported(flavor)) throw new UnsupportedFlavorException(flavor); ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null) { imp = flatten(imp); ImageProcessor ip; if (imp.isComposite()) { ip = new ColorProcessor(imp.getImage()); ip.setRoi(imp.getRoi()); } else ip = imp.getProcessor(); ip = ip.crop(); int w = ip.getWidth(); int h = ip.getHeight(); IJ.showStatus(w+"x"+h+ " image copied to system clipboard"); Image img = IJ.getInstance().createImage(w, h); Graphics g = img.getGraphics(); g.drawImage(ip.createImage(), 0, 0, null); g.dispose(); return img; } else { //IJ.noImage(); return null; } }
void writeImage(ImagePlus imp, String path) throws Exception { if(imp.getBitDepth()==24) biBitCount = 24; else { biBitCount = 8; LookUpTable lut = imp.createLut(); biClrUsed=lut.getMapSize(); // 8 bit color image may use less bfOffBits+=biClrUsed*4; } if (path==null || path.equals("")) { String prompt = "Save as " + biBitCount + " bit BMP"; SaveDialog sd = new SaveDialog(prompt, imp.getTitle(), ".bmp"); if(sd.getFileName()==null) return; path = sd.getDirectory()+sd.getFileName(); } imp.startTiming(); saveBitmap (path, imp.getImage(), imp.getWidth(), imp.getHeight() ); }
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { if (!isDataFlavorSupported(flavor)) throw new UnsupportedFlavorException(flavor); ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null) { imp = flatten(imp); ImageProcessor ip; if (imp.isComposite()) { ip = new ColorProcessor(imp.getImage()); ip.setRoi(imp.getRoi()); } else ip = imp.getProcessor(); ip = ip.crop(); int w = ip.getWidth(); int h = ip.getHeight(); IJ.showStatus(w+"x"+h+ " image copied to system clipboard"); Image img = IJ.getInstance().createImage(w, h); Graphics g = img.getGraphics(); g.drawImage(ip.createImage(), 0, 0, null); g.dispose(); return img; } else { //IJ.noImage(); return null; } }
void writeImage(ImagePlus imp, String path) throws Exception { if(imp.getBitDepth()==24) biBitCount = 24; else { biBitCount = 8; LookUpTable lut = imp.createLut(); biClrUsed=lut.getMapSize(); // 8 bit color image may use less bfOffBits+=biClrUsed*4; } if (path==null || path.equals("")) { String prompt = "Save as " + biBitCount + " bit BMP"; SaveDialog sd = new SaveDialog(prompt, imp.getTitle(), ".bmp"); if(sd.getFileName()==null) return; path = sd.getDirectory()+sd.getFileName(); } imp.startTiming(); saveBitmap (path, imp.getImage(), imp.getWidth(), imp.getHeight() ); }
/** 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); }
@Override public ImagePlus next() { if (nextFrame == nFrames) return null; final ImageStack oldStack = image.getStack(); final String oldTitle = image.getTitle(); final FileInfo fi = image.getFileInfo(); final ImageStack newStack = new ImageStack(w, h); newStack.setColorModel(oldStack.getColorModel()); for (int j = 0; j < nSlices; j++) { final int index = image.getStackIndex(1, j + 1, nextFrame + 1); Object pixels; if (nChannels > 1) { image.setPositionWithoutUpdate(1, j + 1, nextFrame + 1); pixels = new ColorProcessor(image.getImage()).getPixels(); } else { pixels = oldStack.getPixels(index); } newStack.addSlice(oldStack.getSliceLabel(index), pixels); } final ImagePlus ret = new ImagePlus(oldTitle + " (frame " + nextFrame + ")", newStack); ret.setCalibration(image.getCalibration().copy()); ret.setFileInfo((FileInfo) fi.clone()); nextFrame++; return ret; } }
/** Converts this ImagePlus to 8-bit grayscale. */ public synchronized void convertToGray8() { if (imp.getStackSize()>1) { new StackConverter(imp).convertToGray8(); return; } ImageProcessor ip = imp.getProcessor(); if (type==ImagePlus.GRAY16 || type==ImagePlus.GRAY32) { imp.setProcessor(null, ip.convertToByte(doScaling)); imp.setCalibration(imp.getCalibration()); //update calibration record(); } else if (type==ImagePlus.COLOR_RGB) imp.setProcessor(null, ip.convertToByte(doScaling)); else if (ip.isPseudoColorLut()) { boolean invertedLut = ip.isInvertedLut(); ip.setColorModel(LookUpTable.createGrayscaleColorModel(invertedLut)); imp.updateAndDraw(); } else { ip = new ColorProcessor(imp.getImage()); imp.setProcessor(null, ip.convertToByte(doScaling)); } ImageProcessor ip2 = imp.getProcessor(); if (Prefs.useInvertingLut && ip2 instanceof ByteProcessor && !ip2.isInvertedLut()&& !ip2.isColorLut()) { ip2.invertLut(); ip2.invert(); } }
/** Converts this ImagePlus to 8-bit grayscale. */ public synchronized void convertToGray8() { if (imp.getStackSize()>1) { new StackConverter(imp).convertToGray8(); return; } ImageProcessor ip = imp.getProcessor(); if (type==ImagePlus.GRAY16 || type==ImagePlus.GRAY32) { imp.setProcessor(null, ip.convertToByte(doScaling)); imp.setCalibration(imp.getCalibration()); //update calibration record(); } else if (type==ImagePlus.COLOR_RGB) imp.setProcessor(null, ip.convertToByte(doScaling)); else if (ip.isPseudoColorLut()) { boolean invertedLut = ip.isInvertedLut(); ip.setColorModel(LookUpTable.createGrayscaleColorModel(invertedLut)); imp.updateAndDraw(); } else { ip = new ColorProcessor(imp.getImage()); imp.setProcessor(null, ip.convertToByte(doScaling)); } ImageProcessor ip2 = imp.getProcessor(); if (Prefs.useInvertingLut && ip2 instanceof ByteProcessor && !ip2.isInvertedLut()&& !ip2.isColorLut()) { ip2.invertLut(); ip2.invert(); } }