@Override public ColorModel getColorModel() { record("getColorModel"); return proc.getColorModel(); }
@Override public ColorModel getColorModel() { record("getColorModel"); return proc.getColorModel(); }
Color getColor(int index){ IndexColorModel cm = (IndexColorModel)imp.getProcessor().getColorModel(); return new Color(cm.getRGB(index)); }
/** Converts a ByteProcessor to a ShortProcessor. */ ShortProcessor convertByteToShort() { byte[] pixels8 = (byte[])ip.getPixels(); short[] pixels16 = new short[width * height]; for (int i=0,j=0; i<width*height; i++) pixels16[i] = (short)(pixels8[i]&0xff); return new ShortProcessor(width, height, pixels16, ip.getColorModel()); }
ColorModel colormodel(final int c) { if (imagetype == IMAGE5D) return I5DResource.processor(image,c).getColorModel(); else if (image.isComposite()) return ((CompositeImage)image).getChannelLut(c); else return image.getProcessor().getColorModel(); }
void updateLut() { IndexColorModel cm = (IndexColorModel)imp.getChannelProcessor().getColorModel(); if (mapSize == 0) return; cm.getReds(reds); cm.getGreens(greens); cm.getBlues(blues); for(int i=0; i<mapSize; i++) c[i] = new Color(reds[i]&255, greens[i]&255, blues[i]&255); }
/** Returns an empty image stack that has the same width, height and color table as this image. */ public ImageStack createEmptyStack() { ColorModel cm; if (ip!=null) cm = ip.getColorModel(); else cm = createLut().getColorModel(); return new ImageStack(width, height, cm); }
public LUT getLut() { ColorModel cm2 = getColorModel(); if (cm2!=null && (cm2 instanceof IndexColorModel)) return new LUT((IndexColorModel)cm2, getMin(), getMax()); else return null; }
/** Updates this stack so its attributes, such as min, max, calibration table and color model, are the same as 'ip'. */ public void update(ImageProcessor ip) { if (ip!=null) { min = ip.getMin(); max = ip.getMax(); cTable = ip.getCalibrationTable(); cm = ip.getColorModel(); } }
/** * Called from constructor Image5D(String title, ImageProcessor ip) in call to * this(). Checks if ip is null and creates a stack from it. */ static private ImageStack createStackFromProcessor(final ImageProcessor ip) { if (ip == null) throw new IllegalArgumentException( "ImageProcessor is null."); final ImageStack is = new ImageStack(ip.getWidth(), ip.getHeight(), ip.getColorModel()); is.addSlice("", ip); return is; }
@Override public void colorUpdated(Color3f newColor) { if (newColor == null) { final int val = c.getImage().getProcessor().getColorModel().getRGB(c.getThreshold()); newColor = new Color3f(new Color(val)); } mesh.setColor(newColor); }
/** Creates a LookUpTable object that corresponds to this image. */ public LookUpTable createLut() { ImageProcessor ip2 = getProcessor(); if (ip2!=null) return new LookUpTable(ip2.getColorModel()); else return new LookUpTable(LookUpTable.createGrayscaleColorModel(false)); }
/** Adds the image in 'ip' to the end of the stack, setting the string 'sliceLabel' as the slice metadata. */ public void addSlice(String sliceLabel, ImageProcessor ip) { if (ip.getWidth()!=width || ip.getHeight()!=height) throw new IllegalArgumentException("ImageStack.addSlice(): dimensions do not match"); if (nSlices==0) { cm = ip.getColorModel(); min = ip.getMin(); max = ip.getMax(); } addSlice(sliceLabel, ip.getPixels()); }
/** Returns a PatchImage object containing the bottom-of-transformation-stack image and alpha mask, if any (except the AffineTransform, which is used for direct hw-accel screen rendering). */ public Patch.PatchImage createTransformedImage() { final Patch.PatchImage pi = createCoordinateTransformedImage(); if (null != pi) return pi; // else, a new one with the untransformed, original image (a duplicate): final ImageProcessor ip = getImageProcessor(); if (null == ip) return null; project.getLoader().releaseToFit(o_width, o_height, type, 3); final ImageProcessor copy = ip.duplicate(); copy.setColorModel(ip.getColorModel()); // one would expect "duplicate" to do this but it doesn't! return new PatchImage(copy, getAlphaMask(), null, new Rectangle(0, 0, o_width, o_height), false); }
/** Returns a byte[3][256] containing the colors of the fire LUT. */ public static final IndexColorModel fireLUT() { final ImagePlus imp = new ImagePlus("fire", new ByteProcessor(1, 1)); IJ.run(imp, "Fire", ""); return (IndexColorModel) imp.getProcessor().getColorModel(); }
private static ImageStack sortStack(ImageStack stack, String[] strings) { ImageProcessor ip = stack.getProcessor(1); ImageStack stack2 = new ImageStack(ip.getWidth(), ip.getHeight(), ip.getColorModel()); for (int i=0; i<stack.getSize(); i++) { int slice = (int)Tools.parseDouble(strings[i].substring(strings[i].length()-MAX_DIGITS), 0.0); if (slice==0) return null; stack2.addSlice(sliceLabels[slice-1], stack.getPixels(slice)); } stack2.update(stack.getProcessor(1)); return stack2; }
void invertLookupTable() { int nImages = getStackSize(); ip.invertLut(); if (nImages==1) ip.invert(); else { ImageStack stack2 = getStack(); for (int i=1; i<=nImages; i++) stack2.getProcessor(i).invert(); stack2.setColorModel(ip.getColorModel()); } }
void invertLookupTable() { int nImages = getStackSize(); ip.invertLut(); if (nImages==1) ip.invert(); else { ImageStack stack2 = getStack(); for (int i=1; i<=nImages; i++) stack2.getProcessor(i).invert(); stack2.setColorModel(ip.getColorModel()); } }
ImageStack convertToRealStack(ImagePlus imp) { ImageStack stack2 = new ImageStack(imageWidth, imageHeight, imp.getProcessor().getColorModel()); int n = this.getSize(); for (int i=1; i<=this.getSize(); i++) { IJ.showProgress(i, n); IJ.showStatus("Opening: "+i+"/"+n); ImageProcessor ip2 = this.getProcessor(i); if (ip2!=null) stack2.addSlice(this.getSliceLabel(i), ip2); } return stack2; }
static void transfer(final ImagePlus src, final ImagePlus dst) { // Calibration: dst.setCalibration(src.getCalibration()); // Color model: final ColorModel cm = src.getProcessor().getColorModel(); dst.getProcessor().setColorModel(cm); dst.getStack().setColorModel(cm); // Min and max displaying: dst.setDisplayRange(src.getDisplayRangeMin(),src.getDisplayRangeMax()); }