protected void makeDefaultColorModel() { cm = getDefaultColorModel(); }
protected void makeDefaultColorModel() { cm = getDefaultColorModel(); }
@Override public IndexColorModel getDefaultColorModel() { record("getDefaultColorModel"); return proc.getDefaultColorModel(); }
@Override public IndexColorModel getDefaultColorModel() { record("getDefaultColorModel"); return proc.getDefaultColorModel(); }
protected SampleModel getIndexSampleModel() { if (sampleModel==null) { IndexColorModel icm = getDefaultColorModel(); WritableRaster wr = icm.createCompatibleWritableRaster(1, 1); sampleModel = wr.getSampleModel(); sampleModel = sampleModel.createCompatibleSampleModel(width, height); } return sampleModel; }
protected SampleModel getIndexSampleModel() { if (sampleModel==null) { IndexColorModel icm = getDefaultColorModel(); WritableRaster wr = icm.createCompatibleWritableRaster(1, 1); sampleModel = wr.getSampleModel(); sampleModel = sampleModel.createCompatibleSampleModel(width, height); } return sampleModel; }
luts.add(lut); ip.setColorModel(ip.getDefaultColorModel());
luts.add(lut); ip.setColorModel(ip.getDefaultColorModel());
public synchronized void setMode(int mode) { if (mode<COMPOSITE || mode>GRAYSCALE) return; if (mode==COMPOSITE && getNChannels()>MAX_CHANNELS) mode = COLOR; for (int i=0; i<MAX_CHANNELS; i++) active[i] = true; if (this.mode!=COMPOSITE && mode==COMPOSITE) img = null; this.mode = mode; if (mode==COLOR || mode==GRAYSCALE) { if (cip!=null) { for (int i=0; i<cip.length; i++) { if (cip[i]!=null) cip[i].setPixels(null); cip[i] = null; } } cip = null; rgbPixels = null; awtImage = null; currentChannel = -1; } if (mode==GRAYSCALE || mode==TRANSPARENT) ip.setColorModel(ip.getDefaultColorModel()); Channels.updateChannels(); }
public synchronized void setMode(int mode) { if (mode<COMPOSITE || mode>GRAYSCALE) return; if (mode==COMPOSITE && getNChannels()>MAX_CHANNELS) mode = COLOR; for (int i=0; i<MAX_CHANNELS; i++) active[i] = true; if (this.mode!=COMPOSITE && mode==COMPOSITE) img = null; this.mode = mode; if (mode==COLOR || mode==GRAYSCALE) { if (cip!=null) { for (int i=0; i<cip.length; i++) { if (cip[i]!=null) cip[i].setPixels(null); cip[i] = null; } } cip = null; rgbPixels = null; awtImage = null; currentChannel = -1; } if (mode==GRAYSCALE || mode==TRANSPARENT) ip.setColorModel(ip.getDefaultColorModel()); Channels.updateChannels(); }
static public ImageProcessor scaleImage(final ImagePlus imp, double mag, final boolean quality) { if (mag > 1) mag = 1; ImageProcessor ip = imp.getProcessor(); if (Math.abs(mag - 1) < 0.000001) return ip; // else, make a properly scaled image: // - gaussian blurred for best quality when resizing with nearest neighbor // - direct nearest neighbor otherwise final int w = ip.getWidth(); final int h = ip.getHeight(); // TODO releseToFit ! if (quality) { // apply proper gaussian filter final double sigma = Math.sqrt(Math.pow(2, getMipMapLevel(mag, Math.max(imp.getWidth(), imp.getHeight()))) - 0.25); // sigma = sqrt(level^2 - 0.5^2) ip = new FloatProcessorT2(w, h, ImageFilter.computeGaussianFastMirror(new FloatArray2D((float[])ip.convertToFloat().getPixels(), w, h), (float)sigma).data, ip.getDefaultColorModel(), ip.getMin(), ip.getMax()); ip = ip.resize((int)(w * mag), (int)(h * mag)); // better while float return Utils.convertTo(ip, imp.getType(), false); } else { return ip.resize((int)(w * mag), (int)(h * mag)); } }
static public ImageProcessor scaleImage(final ImagePlus imp, final int level, final boolean quality) { if (level <= 0) return imp.getProcessor(); // else, make a properly scaled image: // - gaussian blurred for best quality when resizing with nearest neighbor // - direct nearest neighbor otherwise ImageProcessor ip = imp.getProcessor(); final int w = ip.getWidth(); final int h = ip.getHeight(); final double mag = 1 / Math.pow(2, level); // TODO releseToFit ! if (quality) { // apply proper gaussian filter final double sigma = Math.sqrt(Math.pow(2, level) - 0.25); // sigma = sqrt(level^2 - 0.5^2) ip = new FloatProcessorT2(w, h, ImageFilter.computeGaussianFastMirror(new FloatArray2D((float[])ip.convertToFloat().getPixels(), w, h), (float)sigma).data, ip.getDefaultColorModel(), ip.getMin(), ip.getMax()); ip = ip.resize((int)(w * mag), (int)(h * mag)); // better while float return Utils.convertTo(ip, imp.getType(), false); } else { return ip.resize((int)(w * mag), (int)(h * mag)); } }
ImageStack getRGBStack(ImagePlus imp) { ImageProcessor ip = imp.getProcessor(); int w = ip.getWidth(); int h = ip.getHeight(); int size = w*h; byte[] r = new byte[size]; byte[] g = new byte[size]; byte[] b = new byte[size]; ((ColorProcessor)ip).getRGB(r, g, b); ImageStack stack = new ImageStack(w, h); stack.addSlice("Red", r); stack.addSlice("Green", g); stack.addSlice("Blue", b); stack.setColorModel(ip.getDefaultColorModel()); return stack; }
ImageStack getRGBStack(ImagePlus imp) { ImageProcessor ip = imp.getProcessor(); int w = ip.getWidth(); int h = ip.getHeight(); int size = w*h; byte[] r = new byte[size]; byte[] g = new byte[size]; byte[] b = new byte[size]; ((ColorProcessor)ip).getRGB(r, g, b); ImageStack stack = new ImageStack(w, h); stack.addSlice("Red", r); stack.addSlice("Green", g); stack.addSlice("Blue", b); stack.setColorModel(ip.getDefaultColorModel()); return stack; }
ColorModel cm = ip.getColorModel(); if (ip.isInvertedLut()) cm = ip.getDefaultColorModel(); int size = ip.getWidth()*ip.getHeight(); srcPixels = new int[size];
void convertHSToStack(ImagePlus imp) { if (!(imp.isHyperStack()||imp.isComposite())) return; ImagePlus imp2 = imp; if (imp.isComposite()) { ImageStack stack = imp.getStack(); imp2 = imp.createImagePlus(); imp2.setStack(imp.getTitle(), stack); int[] dim = imp.getDimensions(); imp2.setDimensions(dim[2], dim[3], dim[4]); ImageProcessor ip2 = imp2.getProcessor(); ip2.setColorModel(ip2.getDefaultColorModel()); } imp2.setOpenAsHyperStack(false); if (imp.getWindow()!=null || imp!=imp2) new StackWindow(imp2); if (imp!=imp2) { imp2.setOverlay(imp.getOverlay()); imp.hide(); } }
void convertHSToStack(ImagePlus imp) { if (!(imp.isHyperStack()||imp.isComposite())) return; ImagePlus imp2 = imp; if (imp.isComposite()) { ImageStack stack = imp.getStack(); imp2 = imp.createImagePlus(); imp2.setStack(imp.getTitle(), stack); int[] dim = imp.getDimensions(); imp2.setDimensions(dim[2], dim[3], dim[4]); ImageProcessor ip2 = imp2.getProcessor(); ip2.setColorModel(ip2.getDefaultColorModel()); } imp2.setOpenAsHyperStack(false); if (imp.getWindow()!=null || imp!=imp2) new StackWindow(imp2); if (imp!=imp2) { imp2.setOverlay(imp.getOverlay()); imp.hide(); } }
ip.setColorModel(ip.getDefaultColorModel());
ip.setColorModel(ip.getDefaultColorModel());
ip.setColorModel(ip.getDefaultColorModel()); ip.resetThreshold();