public ImageProcessor getProcessor() { if (ip!=null) return ip; else { ip = new ColorProcessor(img); return ip; } }
public ImageProcessor crop() { int[] pixels2 = new int[roiWidth*roiHeight]; for (int ys=roiY; ys<roiY+roiHeight; ys++) { int offset1 = (ys-roiY)*roiWidth; int offset2 = ys*width+roiX; for (int xs=0; xs<roiWidth; xs++) pixels2[offset1++] = pixels[offset2++]; } ColorProcessor cp2 = new ColorProcessor(roiWidth, roiHeight, pixels2); return cp2; }
@Override public ImageProcessor getProcessor() { return new ColorProcessor(w, h, pixels); } }
public ImageProcessor getProcessor() { if (ip!=null) return ip; else { ip = new ColorProcessor(img); return ip; } }
/** Returns a duplicate of this image. */ public ImageProcessor duplicate() { int[] pixels2 = new int[width*height]; System.arraycopy(pixels, 0, pixels2, 0, width*height); return new ColorProcessor(width, height, pixels2); }
/** Returns a new, blank ColorProcessor with the specified width and height. */ public ImageProcessor createProcessor(int width, int height) { ImageProcessor ip2 = new ColorProcessor(width, height); ip2.setInterpolationMethod(interpolationMethod); return ip2; }
int[] readJPEG(InputStream in) throws IOException { BufferedImage bi = ImageIO.read(in); ImageProcessor ip = new ColorProcessor(bi); return (int[])ip.getPixels(); }
private static final ImageProcessor createProcessor(final int w, final int h, final int type) { if (type == ImagePlus.COLOR_RGB) return new ColorProcessor(w, h); return new ByteProcessor(w, h); } }
private static final ImageProcessor createProcessor( final int w, final int h, final int type) { if(type == ImagePlus.COLOR_RGB) return new ColorProcessor(w, h); return new ByteProcessor(w, h); } }
/** Converts processor to a ColorProcessor. */ public ImageProcessor convertToRGB() { if (type==RGB) return ip; else { ImageProcessor ip2 = ip.convertToByte(doScaling); return new ColorProcessor(ip2.createImage()); } }
public void setZeroTransparent(boolean zeroTransparent) { if (this.zeroTransparent!=zeroTransparent) { ip = makeZeroTransparent(new ColorProcessor(img), zeroTransparent); img = ip.createImage(); } this.zeroTransparent = zeroTransparent; }
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; }
private void writeFourChannelsWithAlpha(ImagePlus imp, String path) throws Exception { ImageStack stack = imp.getStack(); int w=imp.getWidth(), h=imp.getHeight(); ImagePlus imp2 = new ImagePlus("", new ColorProcessor(w,h)); ColorProcessor cp = (ColorProcessor)imp2.getProcessor(); for (int channel=1; channel<=4; channel++) cp.setChannel(channel, (ByteProcessor)stack.getProcessor(channel)); BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); WritableRaster raster = bi.getRaster(); raster.setDataElements(0, 0, w, h, cp.getPixels()); ImageIO.write(bi, "png", new File(path)); }
static public final ImageProcessor createProcessor(final int type, final int width, final int height) { switch (type) { case ImagePlus.GRAY8: return new ByteProcessor(width, height); case ImagePlus.GRAY16: return new ShortProcessor(width, height); case ImagePlus.GRAY32: return new FloatProcessor(width, height); case ImagePlus.COLOR_RGB: return new ColorProcessor(width, height); } return null; }
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; }
/** 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(); }
private static ImageProcessor RGBtoLab(ImageProcessor ip) { int n = ip.getPixelCount(); byte[] L = new byte[n]; byte[] a = new byte[n]; byte[] b = new byte[n]; ColorThresholder.getLab(ip, L, a, b); ColorProcessor cp = new ColorProcessor(ip.getWidth(),ip.getHeight()); cp.setRGB(L,a,b); return cp; }
public ImagePlus createResult() { ImageStack stack = new ImageStack(w, h); for(int z = 0; z < d; z++) { stack.addSlice("", new ColorProcessor(w, h, result[z])); } ImagePlus ret = new ImagePlus("Result", stack); ret.setCalibration(image.getCalibration()); return ret; }