private ImageProcessor shrinkRGB(ColorProcessor cp, ColorProcessor cp2, int method) { ByteProcessor bp = cp.getChannel(1, null); cp2.setChannel(1, (ByteProcessor)shrink(bp, method)); cp2.setChannel(2, (ByteProcessor)shrink(cp.getChannel(2,bp), method)); cp2.setChannel(3, (ByteProcessor)shrink(cp.getChannel(3,bp), method)); return cp2; }
private ImageProcessor shrinkRGB(ColorProcessor cp, ColorProcessor cp2, int method) { ByteProcessor bp = cp.getChannel(1, null); cp2.setChannel(1, (ByteProcessor)shrink(bp, method)); cp2.setChannel(2, (ByteProcessor)shrink(cp.getChannel(2,bp), method)); cp2.setChannel(3, (ByteProcessor)shrink(cp.getChannel(3,bp), method)); return cp2; }
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)); }
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)); }
private static void fillNoiseRGB(ColorProcessor ip, boolean sp) { int width = ip.getWidth(); int height = ip.getHeight(); ByteProcessor rr = new ByteProcessor(width, height); ByteProcessor gg = new ByteProcessor(width, height); ByteProcessor bb = new ByteProcessor(width, height); if (sp) IJ.showProgress(0.0); rr.add(127); if (sp) IJ.showProgress(0.05); gg.add(127); if (sp) IJ.showProgress(0.10); bb.add(127); if (sp) IJ.showProgress(0.15); rr.noise(31); if (sp) IJ.showProgress(0.40); gg.noise(31); if (sp) IJ.showProgress(0.65); bb.noise(31); if (sp) IJ.showProgress(0.90); if (sp) IJ.showProgress(1.0); ip.setChannel(1,rr); ip.setChannel(2,gg); ip.setChannel(3,bb); }
private static void fillNoiseRGB(ColorProcessor ip, boolean sp) { int width = ip.getWidth(); int height = ip.getHeight(); ByteProcessor rr = new ByteProcessor(width, height); ByteProcessor gg = new ByteProcessor(width, height); ByteProcessor bb = new ByteProcessor(width, height); if (sp) IJ.showProgress(0.0); rr.add(127); if (sp) IJ.showProgress(0.05); gg.add(127); if (sp) IJ.showProgress(0.10); bb.add(127); if (sp) IJ.showProgress(0.15); rr.noise(31); if (sp) IJ.showProgress(0.40); gg.noise(31); if (sp) IJ.showProgress(0.65); bb.noise(31); if (sp) IJ.showProgress(0.90); if (sp) IJ.showProgress(1.0); ip.setChannel(1,rr); ip.setChannel(2,gg); ip.setChannel(3,bb); }
ByteProcessor b2 = (ByteProcessor)getChannel(3,null).resizeLinearly(dstWidth, dstHeight); ColorProcessor ip2 = new ColorProcessor(dstWidth, dstHeight); ip2.setChannel(1, r2); ip2.setChannel(2, g2); ip2.setChannel(3, b2); return ip2;
ByteProcessor b2 = (ByteProcessor)getChannel(3,null).resizeLinearly(dstWidth, dstHeight); ColorProcessor ip2 = new ColorProcessor(dstWidth, dstHeight); ip2.setChannel(1, r2); ip2.setChannel(2, g2); ip2.setChannel(3, b2); return ip2;