/** * Replaces the AWT image, if any, with the one specified. Throws an * IllegalStateException if an error occurs while loading the image. Use of * this method is untested. */ @Override public void setImage(final Image img) { // Avoid messing up of image window (5D) by superclass, which doesn't know // about 5D. final ImageWindow tempWin = win; win = null; super.setImage(img); win = tempWin; // Now tell the Image5DWindow (if any) to update itself. }
/** Constructs an ImagePlus from an Image or BufferedImage. The first argument will be used as the title of the window that displays the image. Throws an IllegalStateException if an error occurs while loading the image. */ public ImagePlus(String title, Image image) { this.title = title; if (image!=null) setImage(image); setID(); }
/** Constructs an ImagePlus from an Image or BufferedImage. The first argument will be used as the title of the window that displays the image. Throws an IllegalStateException if an error occurs while loading the image. */ public ImagePlus(String title, Image image) { this.title = title; if (image!=null) setImage(image); setID(); }
File inputFile = new File("someImage.png"); Image someImage = null; try { someImage = ImageIO.read(inputFile); } catch (IOException e) { e.printStackTrace(); } ImagePlus imagePlus = new ImagePlus(); imagePlus.setImage(someImage); ColorProcessor processor = (ColorProcessor) imagePlus.getProcessor();
/** Converts a Lab stack to RGB. */ public void convertLabToRGB() { if (imp.getStackSize()!=3) throw new IllegalArgumentException("3-slice 32-bit stack required"); ColorSpaceConverter converter = new ColorSpaceConverter(); ImagePlus imp2 = converter.LabToRGB(imp); imp2.setCalibration(imp.getCalibration()); imp.setImage(imp2); }
/** Converts a Lab stack to RGB. */ public void convertLabToRGB() { if (imp.getStackSize()!=3) throw new IllegalArgumentException("3-slice 32-bit stack required"); ColorSpaceConverter converter = new ColorSpaceConverter(); ImagePlus imp2 = converter.LabToRGB(imp); imp2.setCalibration(imp.getCalibration()); imp.setImage(imp2); }
/** Converts a 3-slice (hue, saturation, brightness) 8-bit stack to RGB. */ public void convertHSBToRGB() { if (imp.getStackSize()!=3) throw new IllegalArgumentException("3-slice 8-bit stack required"); ImageStack stack = imp.getStack(); byte[] H = (byte[])stack.getPixels(1); byte[] S = (byte[])stack.getPixels(2); byte[] B = (byte[])stack.getPixels(3); int width = imp.getWidth(); int height = imp.getHeight(); imp.trimProcessor(); ColorProcessor cp = new ColorProcessor(width, height); cp.setHSB(H, S, B); imp.setImage(cp.createImage()); imp.killStack(); if (IJ.isLinux()) imp.setTitle(imp.getTitle()); }
/** Converts a 3-slice (hue, saturation, brightness) 8-bit stack to RGB. */ public void convertHSBToRGB() { if (imp.getStackSize()!=3) throw new IllegalArgumentException("3-slice 8-bit stack required"); ImageStack stack = imp.getStack(); byte[] H = (byte[])stack.getPixels(1); byte[] S = (byte[])stack.getPixels(2); byte[] B = (byte[])stack.getPixels(3); int width = imp.getWidth(); int height = imp.getHeight(); imp.trimProcessor(); ColorProcessor cp = new ColorProcessor(width, height); cp.setHSB(H, S, B); imp.setImage(cp.createImage()); imp.killStack(); if (IJ.isLinux()) imp.setTitle(imp.getTitle()); }
imp0 = imp2; } else imp0.setImage(imp2); return "ok";
imp0 = imp2; } else imp0.setImage(imp2); return "ok";
private static void filterHyperstack(ImagePlus imp, int filter, float vx, float vy, float vz) { if (imp.getNDimensions()>4) { IJ.error("5D hyperstacks are currently not supported"); return; } if (imp.getNChannels()==1) { ImageStack stack = filter(imp.getStack(), filter, vx, vy, vz); imp.setStack(stack); return; } ImagePlus[] channels = ChannelSplitter.split(imp); int n = channels.length; for (int i=0; i<n; i++) { ImageStack stack = filter(channels[i].getStack(), filter, vx, vy, vz); channels[i].setStack(stack); } ImagePlus imp2 = RGBStackMerge.mergeChannels(channels, false); imp.setImage(imp2); imp.setC(1); }
private static void filterHyperstack(ImagePlus imp, int filter, float vx, float vy, float vz) { if (imp.getNDimensions()>4) { IJ.error("5D hyperstacks are currently not supported"); return; } if (imp.getNChannels()==1) { ImageStack stack = filter(imp.getStack(), filter, vx, vy, vz); imp.setStack(stack); return; } ImagePlus[] channels = ChannelSplitter.split(imp); int n = channels.length; for (int i=0; i<n; i++) { ImageStack stack = filter(channels[i].getStack(), filter, vx, vy, vz); channels[i].setStack(stack); } ImagePlus imp2 = RGBStackMerge.mergeChannels(channels, false); imp.setImage(imp2); imp.setC(1); }
/** Converts a 2 or 3 slice 8-bit stack to RGB. */ public void convertRGBStackToRGB() { int stackSize = imp.getStackSize(); if (stackSize<2 || stackSize>3 || type!=ImagePlus.GRAY8) throw new IllegalArgumentException("2 or 3 slice 8-bit stack required"); int width = imp.getWidth(); int height = imp.getHeight(); ImageStack stack = imp.getStack(); byte[] R = (byte[])stack.getPixels(1); byte[] G = (byte[])stack.getPixels(2); byte[] B; if (stackSize>2) B = (byte[])stack.getPixels(3); else B = new byte[width*height]; imp.trimProcessor(); ColorProcessor cp = new ColorProcessor(width, height); cp.setRGB(R, G, B); if (imp.isInvertedLut()) cp.invert(); imp.setImage(cp.createImage()); imp.killStack(); if (IJ.isLinux()) imp.setTitle(imp.getTitle()); }
/** Converts a 2 or 3 slice 8-bit stack to RGB. */ public void convertRGBStackToRGB() { int stackSize = imp.getStackSize(); if (stackSize<2 || stackSize>3 || type!=ImagePlus.GRAY8) throw new IllegalArgumentException("2 or 3 slice 8-bit stack required"); int width = imp.getWidth(); int height = imp.getHeight(); ImageStack stack = imp.getStack(); byte[] R = (byte[])stack.getPixels(1); byte[] G = (byte[])stack.getPixels(2); byte[] B; if (stackSize>2) B = (byte[])stack.getPixels(3); else B = new byte[width*height]; imp.trimProcessor(); ColorProcessor cp = new ColorProcessor(width, height); cp.setRGB(R, G, B); if (imp.isInvertedLut()) cp.invert(); imp.setImage(cp.createImage()); imp.killStack(); if (IJ.isLinux()) imp.setTitle(imp.getTitle()); }
imp.setImage(imp2); return;
imp.setImage(imp2); return;