/** Returns an 8-bit version of this image as a ByteProcessor. 16-bit and 32-bit * pixel data are scaled from min-max to 0-255 if 'scale' is true. */ public ByteProcessor convertToByteProcessor(boolean scale) { ByteProcessor bp; if (this instanceof ByteProcessor) bp = (ByteProcessor)this.duplicate(); else bp = (ByteProcessor)this.convertToByte(scale); return bp; }
/** Returns an 8-bit version of this image as a ByteProcessor. 16-bit and 32-bit * pixel data are scaled from min-max to 0-255 if 'scale' is true. */ public ByteProcessor convertToByteProcessor(boolean scale) { ByteProcessor bp; if (this instanceof ByteProcessor) bp = (ByteProcessor)this.duplicate(); else bp = (ByteProcessor)this.convertToByte(scale); return bp; }
@Override public ImageProcessor convertToByte(boolean doScaling) { record("convertToByte", new Boolean(doScaling), boolean.class); return proc.convertToByte(doScaling); }
@Override public ImageProcessor convertToByte(boolean doScaling) { record("convertToByte", new Boolean(doScaling), boolean.class); return proc.convertToByte(doScaling); }
/** Converts processor to a ColorProcessor. */ public ImageProcessor convertToRGB() { if (type==RGB) return ip; else { ImageProcessor ip2 = ip.convertToByte(doScaling); return new ColorProcessor(ip2.createImage()); } }
/** 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 setFromFloatArrays(float[][] arrays) { ImageProcessor ip2 = new FloatProcessor(roiWidth, roiHeight, arrays[0], null); ip2 = ip2.convertToByte(false); setPixels(ip2.getPixels()); //insert(ip2, roiX, roiY); }
private ImageProcessor convertToOriginalDepth(ImagePlus imp, ImageProcessor ip) { if (imp.getBitDepth()==8) ip = ip.convertToByte(false); else if (imp.getBitDepth()==16) ip = ip.convertToShort(false); return ip; }
public void setFromFloatArrays(float[][] arrays) { ImageProcessor ip2 = new FloatProcessor(roiWidth, roiHeight, arrays[0], null); ip2 = ip2.convertToByte(false); setPixels(ip2.getPixels()); //insert(ip2, roiX, roiY); }
private ImageProcessor convertToOriginalDepth(ImagePlus imp, ImageProcessor ip) { if (imp.getBitDepth()==8) ip = ip.convertToByte(false); else if (imp.getBitDepth()==16) ip = ip.convertToShort(false); return ip; }
/** * Display the whole image after classification */ void showClassificationImage(){ ImagePlus resultImage = new ImagePlus("classification result", classifiedImage.getProcessor().convertToByte(true).duplicate()); resultImage.show(); }
/** * Display the whole image after classification */ void showClassificationImage(){ ImagePlus resultImage = new ImagePlus("classification result", classifiedImage.getProcessor().convertToByte(true).duplicate()); resultImage.show(); }
/** Performs a convolution operation using the specified kernel. */ public void convolve(float[] kernel, int kernelWidth, int kernelHeight) { ImageProcessor ip2 = convertToFloat(); ip2.setRoi(getRoi()); new ij.plugin.filter.Convolver().convolve(ip2, kernel, kernelWidth, kernelHeight); ip2 = ip2.convertToByte(false); byte[] pixels2 = (byte[])ip2.getPixels(); System.arraycopy(pixels2, 0, pixels, 0, pixels.length); }
/** Performs a convolution operation using the specified kernel. */ public void convolve(float[] kernel, int kernelWidth, int kernelHeight) { ImageProcessor ip2 = convertToFloat(); ip2.setRoi(getRoi()); new ij.plugin.filter.Convolver().convolve(ip2, kernel, kernelWidth, kernelHeight); ip2 = ip2.convertToByte(false); byte[] pixels2 = (byte[])ip2.getPixels(); System.arraycopy(pixels2, 0, pixels, 0, pixels.length); }
void saveAs8bitTiff(ImagePlus img, String path) { ImageProcessor ip = img.getProcessor(); if (ip instanceof ColorProcessor) {ip = reduceColors(ip); img.setProcessor(null, ip);} else if ((ip instanceof ShortProcessor) || (ip instanceof FloatProcessor)) {ip = ip.convertToByte(true); img.setProcessor(null, ip);} new FileSaver(img).saveAsTiff(path); }
/** * Update the result image overlay with the corresponding slice */ public void updateResultOverlay() { ImageProcessor overlay = classifiedImage.getImageStack().getProcessor(displayImage.getCurrentSlice()).duplicate(); //IJ.log("updating overlay with result from slice " + displayImage.getCurrentSlice()); overlay = overlay.convertToByte(false); overlay.setColorModel(overlayLUT); win.resultOverlay.setImage(overlay); }
/** * Update the result image overlay with the corresponding slice */ public void updateResultOverlay() { ImageProcessor overlay = classifiedImage.getImageStack().getProcessor(displayImage.getCurrentSlice()).duplicate(); //IJ.log("updating overlay with result from slice " + displayImage.getCurrentSlice()); overlay = overlay.convertToByte(false); overlay.setColorModel(overlayLUT); win.resultOverlay.setImage(overlay); }
/** 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) { boolean temporaryFloat = ip.getBitDepth()==32 && (mode==Blitter.MULTIPLY || mode==Blitter.DIVIDE); if (temporaryFloat) { FloatProcessor ipFloat = this.convertToFloatProcessor(); new FloatBlitter(ipFloat).copyBits(ip, xloc, yloc, mode); setPixels(1, ipFloat); } else { ip = ip.convertToByte(true); new ByteBlitter(this).copyBits(ip, xloc, yloc, mode); } }
public void setSlice(int index, ImageProcessor ip) { String name = preview.getSliceLabel(index); ImagePlus imp = new ImagePlus(name, ip); new FileSaver(imp).saveAsPng(dir + "/" + name); ip = ip.resize(w_prev).convertToByte(true); preview.setPixels(ip.getPixels(), index); }
/** 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) { boolean temporaryFloat = ip.getBitDepth()==32 && (mode==Blitter.MULTIPLY || mode==Blitter.DIVIDE); if (temporaryFloat) { FloatProcessor ipFloat = this.convertToFloatProcessor(); new FloatBlitter(ipFloat).copyBits(ip, xloc, yloc, mode); setPixels(1, ipFloat); } else { ip = ip.convertToByte(true); new ByteBlitter(this).copyBits(ip, xloc, yloc, mode); } }