/** Returns 'true' if this is an image with a grayscale LUT or an * RGB image with identical red, green and blue channels. */ public boolean isGrayscale() { return !isColorLut(); }
/** Returns 'true' if this is an image with a grayscale LUT or an * RGB image with identical red, green and blue channels. */ public boolean isGrayscale() { return !isColorLut(); }
@Override public boolean isColorLut() { record("isColorLut"); return proc.isColorLut(); }
@Override public boolean isColorLut() { record("isColorLut"); return proc.isColorLut(); }
public KD(ImageProcessor ip, double ratio, int n, int iter) { this.ip = ip; isColor = ip.isColorLut() || (ip instanceof ColorProcessor); this.ratio = ratio; w = ip.getWidth(); h = ip.getHeight(); c = new int[w * h]; for (int i = 0; i < w * h; i++) c[i] = (int)(Math.random() * n); this.n = n; iterations = iter; }
/** Update type, original dimensions and min,max from the given ImagePlus. */ private void readProps(final ImagePlus imp) { this.type = imp.getType(); this.false_color = imp.getProcessor().isColorLut(); if (imp.getWidth() != (int)this.o_width || imp.getHeight() != this.o_height) { this.o_width = imp.getWidth(); this.o_height = imp.getHeight(); this.width = o_width; this.height = o_height; updateBucket(); } final ImageProcessor ip = imp.getProcessor(); this.min = ip.getMin(); this.max = ip.getMax(); final HashSet<String> keys = new HashSet<String>(); keys.add("type"); keys.add("dimensions"); keys.add("min_and_max"); updateInDatabase(keys); //updateInDatabase(new HashSet<String>(Arrays.asList(new String[]{"type", "dimensions", "min_and_max"}))); }
public static ImagePlus resample(ImagePlus image, int factorX, int factorY, int factorZ) { Accumulator accu = null; int type = image.getType(); if (image.getProcessor().isColorLut()) { if (type==ImagePlus.GRAY8||type==ImagePlus.COLOR_256) accu = new MaxLikelihood(255); else if (type==ImagePlus.GRAY16) accu = new MaxLikelihood((1<<16)-1); } else if(type == ImagePlus.COLOR_RGB) accu = new IntAverager(); else accu = new Averager(); return resample(image, factorX, factorY, factorZ, accu); }
/** Construct a Patch from an image; * most likely you will need to add the file path to the {@code imp} * by calling {@link Loader#addedPatchFrom(String, Patch)}, as in this example: * * project.getLoader().addedPatchFrom("/path/to/file.png", thePatch); */ public Patch(final Project project, final String title, final double x, final double y, final ImagePlus imp) { super(project, title, x, y); this.type = imp.getType(); // Color LUT in ImageJ is a nightmare of inconsistency. We set the COLOR_256 only for 8-bit images that are LUT images themselves; not for 16 or 32-bit images that may have a color LUT (which, by the way, ImageJ tiff encoder cannot save with the tif file.) if (ImagePlus.GRAY8 == this.type && imp.getProcessor().isColorLut()) this.type = ImagePlus.COLOR_256; this.min = imp.getProcessor().getMin(); this.max = imp.getProcessor().getMax(); checkMinMax(); this.o_width = imp.getWidth(); this.o_height = imp.getHeight(); this.width = (int)o_width; this.height = (int)o_height; project.getLoader().cache(this, imp); this.false_color = imp.getProcessor().isColorLut(); addToDatabase(); }
if (Prefs.useInvertingLut && getBitDepth()==8 && ip!=null && !ip.isInvertedLut()&& !ip.isColorLut()) invertLookupTable(); if (getProperty("FHT")!=null) {
!image.getProcessor().isColorLut()) interpol = new AverageByte(); else
if (Prefs.useInvertingLut && getBitDepth()==8 && ip!=null && !ip.isInvertedLut()&& !ip.isColorLut()) invertLookupTable(); if (getProperty("FHT")!=null) {
d = ii.d; cumul = new int[ii.d][ii.w * ii.h]; boolean isGray = !image.getProcessor().isColorLut(); Method method = isGray ? (Method)new AverageGray() : (Method)new AverageLabels();
boolean allGrayLuts = true; for (int c=0; c<channels; c++) { if (images[c].getProcessor().isColorLut()) { allGrayLuts = false; break;
return; if (Prefs.useInvertingLut && getBitDepth()==8 && ip!=null && !ip.isInvertedLut()&& !ip.isColorLut()) invertLookupTable(); img = getImage();
return; if (Prefs.useInvertingLut && getBitDepth()==8 && ip!=null && !ip.isInvertedLut()&& !ip.isColorLut()) invertLookupTable(); img = getImage();
/** Converts this ImagePlus to 8-bit grayscale. */ public synchronized void convertToGray8() { if (imp.getStackSize()>1) { new StackConverter(imp).convertToGray8(); return; } ImageProcessor ip = imp.getProcessor(); if (type==ImagePlus.GRAY16 || type==ImagePlus.GRAY32) { imp.setProcessor(null, ip.convertToByte(doScaling)); imp.setCalibration(imp.getCalibration()); //update calibration record(); } else if (type==ImagePlus.COLOR_RGB) imp.setProcessor(null, ip.convertToByte(doScaling)); else if (ip.isPseudoColorLut()) { boolean invertedLut = ip.isInvertedLut(); ip.setColorModel(LookUpTable.createGrayscaleColorModel(invertedLut)); imp.updateAndDraw(); } else { ip = new ColorProcessor(imp.getImage()); imp.setProcessor(null, ip.convertToByte(doScaling)); } ImageProcessor ip2 = imp.getProcessor(); if (Prefs.useInvertingLut && ip2 instanceof ByteProcessor && !ip2.isInvertedLut()&& !ip2.isColorLut()) { ip2.invertLut(); ip2.invert(); } }
/** Converts this ImagePlus to 8-bit grayscale. */ public synchronized void convertToGray8() { if (imp.getStackSize()>1) { new StackConverter(imp).convertToGray8(); return; } ImageProcessor ip = imp.getProcessor(); if (type==ImagePlus.GRAY16 || type==ImagePlus.GRAY32) { imp.setProcessor(null, ip.convertToByte(doScaling)); imp.setCalibration(imp.getCalibration()); //update calibration record(); } else if (type==ImagePlus.COLOR_RGB) imp.setProcessor(null, ip.convertToByte(doScaling)); else if (ip.isPseudoColorLut()) { boolean invertedLut = ip.isInvertedLut(); ip.setColorModel(LookUpTable.createGrayscaleColorModel(invertedLut)); imp.updateAndDraw(); } else { ip = new ColorProcessor(imp.getImage()); imp.setProcessor(null, ip.convertToByte(doScaling)); } ImageProcessor ip2 = imp.getProcessor(); if (Prefs.useInvertingLut && ip2 instanceof ByteProcessor && !ip2.isInvertedLut()&& !ip2.isColorLut()) { ip2.invertLut(); ip2.invert(); } }
if (ip!=null && ip.getMinThreshold()==ImageProcessor.NO_THRESHOLD && ip.isColorLut() && !ip.isPseudoColorLut()) { type = ImagePlus.COLOR_256; imp.setType(ImagePlus.COLOR_256);
int currentSlice = imp.getCurrentSlice(); ImageProcessor ip = imp.getProcessor(); boolean colorLut = ip.isColorLut(); boolean pseudoColorLut = colorLut && ip.isPseudoColorLut(); boolean composite = imp.isComposite();
int currentSlice = imp.getCurrentSlice(); ImageProcessor ip = imp.getProcessor(); boolean colorLut = ip.isColorLut(); boolean pseudoColorLut = colorLut && ip.isPseudoColorLut(); boolean composite = imp.isComposite();