/** Returns an RGB version of this image as a ColorProcessor. */ public ColorProcessor convertToColorProcessor() { ColorProcessor cp; if (this instanceof ColorProcessor) cp = (ColorProcessor)this.duplicate(); else cp = (ColorProcessor)this.convertToRGB(); return cp; }
@Override public ImageProcessor convertToRGB() { record("convertToRGB"); return proc.convertToRGB(); }
@Override public ImageProcessor convertToRGB() { record("convertToRGB"); return proc.convertToRGB(); }
/** Returns an RGB version of this image as a ColorProcessor. */ public ColorProcessor convertToColorProcessor() { ColorProcessor cp; if (this instanceof ColorProcessor) cp = (ColorProcessor)this.duplicate(); else cp = (ColorProcessor)this.convertToRGB(); return cp; }
/** Copies the image contained in 'ip' to (xloc, yloc) using one of the transfer modes defined in the Blitter interface. */ public void copyBits(ImageProcessor ip, int xloc, int yloc, int mode) { ip = ip.convertToRGB(); new ColorBlitter(this).copyBits(ip, xloc, yloc, mode); }
public void fillRoiTransparent(Roi roi) { int index = preview.getCurrentSlice(); Polygon poly = ((PolygonRoi)roi).getPolygon(); ImageProcessor ip = stack.getProcessor(index); ip = ip.convertToRGB(); BufferedImage bi = (BufferedImage)ip.createImage(); Graphics2D g = bi.createGraphics(); Color col = new Color(color); col = new Color(col.getRed(), col.getGreen(), col.getBlue(), alpha); g.setColor(col); g.fill(poly); g.dispose(); stack.setSlice(index, ip); }
/** Copies the image contained in 'ip' to (xloc, yloc) using one of the transfer modes defined in the Blitter interface. */ public void copyBits(ImageProcessor ip, int xloc, int yloc, int mode) { ip = ip.convertToRGB(); new ColorBlitter(this).copyBits(ip, xloc, yloc, mode); }
/** Returns an ImageProcessor for the specified slice, were 1<=n<=nslices. Returns null if the stack is empty. */ public ImageProcessor getProcessor(int n) { byte[] bytes = (byte[])plots.get(n-1); if (bytes!=null) { try { Plot plot = new Plot(null, new ByteArrayInputStream(bytes)); ImageProcessor ip = plot.getProcessor(); if (bitDepth==24) ip = ip.convertToRGB(); else if (bitDepth==8) ip = ip.convertToByte(false); return ip; } catch (Exception e) { IJ.handleException(e); } } return null; }
/** Returns an ImageProcessor for the specified slice, were 1<=n<=nslices. Returns null if the stack is empty. */ public ImageProcessor getProcessor(int n) { byte[] bytes = (byte[])plots.get(n-1); if (bytes!=null) { try { Plot plot = new Plot(null, new ByteArrayInputStream(bytes)); ImageProcessor ip = plot.getProcessor(); if (bitDepth==24) ip = ip.convertToRGB(); else if (bitDepth==8) ip = ip.convertToByte(false); return ip; } catch (Exception e) { IJ.handleException(e); } } return null; }
/** Write RGB data. Each 3-byte triplet in the bitmap array represents * blue, green, and red, respectively, for a pixel. The color bytes are * in reverse order (Windows convention). Lines are padded to a length * that is a multiple of 4 bytes. */ private void writeRGBFrame(ImageProcessor ip) throws IOException { ip = ip.convertToRGB(); int[] pixels = (int[])ip.getPixels(); int width = ip.getWidth(); int height = ip.getHeight(); int c, offset, index = 0; for (int y=height-1; y>=0; y--) { offset = y*width; for (int x=0; x<width; x++) { c = pixels[offset++]; bufferWrite[index++] = (byte)(c&0xff); // blue bufferWrite[index++] = (byte)((c&0xff00)>>8); //green bufferWrite[index++] = (byte)((c&0xff0000)>>16); // red } for (int i = 0; i<linePad; i++) bufferWrite[index++] = (byte)0; } raFile.write(bufferWrite); }
/** Converts the ImageProcessor to an ImageProcessor of the given type, or the same if of equal type. */ static final public ImageProcessor convertTo(final ImageProcessor ip, final int type, final boolean scaling) { switch (type) { case ImagePlus.GRAY8: return ip.convertToByte(scaling); case ImagePlus.GRAY16: return ip.convertToShort(scaling); case ImagePlus.GRAY32: return ip.convertToFloat(); case ImagePlus.COLOR_RGB: return ip.convertToRGB(); case ImagePlus.COLOR_256: final ImagePlus imp = new ImagePlus("", ip.convertToRGB()); new ImageConverter(imp).convertRGBtoIndexedColor(256); return imp.getProcessor(); default: return null; } }
/** 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 }
public void fade(int numSlices) { int index = preview.getCurrentSlice(); int[] before = (int[])(stack.getProcessor(index). convertToRGB().getPixels()); int[] after = (int[])(stack.getProcessor(index+1). convertToRGB().getPixels()); for(int z = 1; z < numSlices; z++) { ColorProcessor bp = new ColorProcessor( stack.getWidth(), stack.getHeight()); int[] pixels = (int[])bp.getPixels(); double dp = z; double dn = numSlices-z; for(int i = 0; i < pixels.length; i++) { pixels[i] = interpolate(before[i], dp, after[i], dn); } if(!stack.addSlice(index + z - 1, bp)) break; } preview.setSlice(preview.getCurrentSlice() + numSlices); }
/** * Add HSB features */ public void addHSB() { final ImagePlus hsb = originalImage.duplicate(); ImageConverter ic = new ImageConverter( hsb ); ic.convertToHSB(); for(int n=1; n<=hsb.getImageStackSize(); n++) wholeStack.addSlice(hsb.getImageStack().getSliceLabel(n), hsb.getImageStack().getProcessor(n).convertToRGB()); }
/** * Add HSB features */ public void addHSB() { final ImagePlus hsb = originalImage.duplicate(); ImageConverter ic = new ImageConverter( hsb ); ic.convertToHSB(); for(int n=1; n<=hsb.getImageStackSize(); n++) wholeStack.addSlice(hsb.getImageStack().getSliceLabel(n), hsb.getImageStack().getProcessor(n).convertToRGB()); }
public ImagePlus createOverlay() { ImageStack stack = new ImageStack(w, h); int RED = 0xff0000; for(int z = 0; z < d; z++) { ImageProcessor ip = image.getStack(). getProcessor(z + 1).convertToRGB(); for(int i = 0; i < w * h; i++) { if(minima[z][i] == (byte)MINIMUM) ip.set(i, RED); } stack.addSlice("", ip); } ImagePlus ret = new ImagePlus("overlay", stack); ret.setCalibration(image.getCalibration()); return ret; }
final public Image createImage(final double min, final double max) { final ImageProcessor ip = target; ip.setMinAndMax(min, max); ByteProcessor alpha_mask = mask; // can be null; final ByteProcessor outside_mask = outside; // can be null if (null == alpha_mask) { alpha_mask = outside_mask; } if (null != alpha_mask) { return ImageSaver.createARGBImagePre( Loader.embedAlphaPre((int[])ip.convertToRGB().getPixels(), (byte[])alpha_mask.getPixels(), null == outside_mask ? null : (byte[])outside_mask.getPixels()), ip.getWidth(), ip.getHeight()); } else { return ip.createImage(); } } }
public ImagePlus call(){ final ImagePlus hsb = originalImage.duplicate(); ImageConverter ic = new ImageConverter( hsb ); ic.convertToHSB(); ImageStack is = new ImageStack(originalImage.getWidth(), originalImage.getHeight()); for(int n=1; n<=hsb.getImageStackSize(); n++) is.addSlice(hsb.getImageStack().getSliceLabel(n), hsb.getImageStack().getProcessor(n).convertToRGB()); return new ImagePlus ("HSB", is); } };
public ImagePlus call(){ final ImagePlus hsb = originalImage.duplicate(); ImageConverter ic = new ImageConverter( hsb ); ic.convertToHSB(); ImageStack is = new ImageStack(originalImage.getWidth(), originalImage.getHeight()); for(int n=1; n<=hsb.getImageStackSize(); n++) is.addSlice(hsb.getImageStack().getSliceLabel(n), hsb.getImageStack().getProcessor(n).convertToRGB()); return new ImagePlus ("HSB", is); } };