private int getType(ImageProcessor ip) { int bitDepth = ip.getBitDepth(); switch (bitDepth) { case 8: return BYTE; case 16: return SHORT; case 32: return FLOAT; case 24: return RGB; } return UNKNOWN; }
private int getType(ImageProcessor ip) { int bitDepth = ip.getBitDepth(); switch (bitDepth) { case 8: return BYTE; case 16: return SHORT; case 32: return FLOAT; case 24: return RGB; } return UNKNOWN; }
/** Returns a string containing information about this ImageProcessor. */ public String toString() { return ("ip[width="+width+", height="+height+", bits="+getBitDepth()+", min="+getMin()+", max="+getMax()+"]"); }
/** Returns a string containing information about this ImageProcessor. */ public String toString() { return ("ip[width="+width+", height="+height+", bits="+getBitDepth()+", min="+getMin()+", max="+getMax()+"]"); }
/** Converts the specified RGB image to 8-bits if the 3 channels are identical. */ public static void convertGrayJpegTo8Bits(ImagePlus imp) { ImageProcessor ip = imp.getProcessor(); if (ip.getBitDepth()==24 && ip.isGrayscale()) { IJ.showStatus("Converting to 8-bit grayscale"); new ImageConverter(imp).convertToGray8(); } }
/** Converts the specified RGB image to 8-bits if the 3 channels are identical. */ public static void convertGrayJpegTo8Bits(ImagePlus imp) { ImageProcessor ip = imp.getProcessor(); if (ip.getBitDepth()==24 && ip.isGrayscale()) { IJ.showStatus("Converting to 8-bit grayscale"); new ImageConverter(imp).convertToGray8(); } }
private void resetMinAndMax(ImageProcessor ip) { if (ip.getBitDepth()!=8 && (!noReset || mode==OVER_UNDER)) { ImageStatistics stats = ip.getStats(); if (ip.getMin()!=stats.min || ip.getMax()!=stats.max) { ip.resetMinAndMax(); ContrastAdjuster.update(); } else ip.resetMinAndMax(); } }
private void resetMinAndMax(ImageProcessor ip) { if (ip.getBitDepth()!=8 && (!noReset || mode==OVER_UNDER)) { ImageStatistics stats = ip.getStats(); if (ip.getMin()!=stats.min || ip.getMax()!=stats.max) { ip.resetMinAndMax(); ContrastAdjuster.update(); } else ip.resetMinAndMax(); } }
/** 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.convertToShort(false); new ShortBlitter(this).copyBits(ip, xloc, yloc, mode); } }
/** 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); } }
/** 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); } }
void customFilter(FHT fht) { int size = fht.getWidth(); showStatus("Filtering"); fht.swapQuadrants(filter); float[] fhtPixels = (float[])fht.getPixels(); boolean isFloat = filter.getBitDepth()==32; for (int i=0; i<fhtPixels.length; i++) { if (isFloat) fhtPixels[i] = fhtPixels[i]*filter.getf(i); else fhtPixels[i] = (float)(fhtPixels[i]*(filter.get(i)/255.0)); } fht.swapQuadrants(filter); }
/** 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.convertToShort(false); new ShortBlitter(this).copyBits(ip, xloc, yloc, mode); } }
void customFilter(FHT fht) { int size = fht.getWidth(); showStatus("Filtering"); fht.swapQuadrants(filter); float[] fhtPixels = (float[])fht.getPixels(); boolean isFloat = filter.getBitDepth()==32; for (int i=0; i<fhtPixels.length; i++) { if (isFloat) fhtPixels[i] = fhtPixels[i]*filter.getf(i); else fhtPixels[i] = (float)(fhtPixels[i]*(filter.get(i)/255.0)); } fht.swapQuadrants(filter); }
void reset(ImagePlus imp, ImageProcessor ip) { if (noResetChanged) { noResetChanged = false; if ((noReset&&mode!=OVER_UNDER) || ip.getBitDepth()==8) return; if (!noReset) { ImageStatistics stats = ip.getStats(); if (ip.getMin()==stats.min && ip.getMax()==stats.max) return; // not contrast enhanced; no need to reset } } ip.resetThreshold(); if (!noReset) resetMinAndMax(ip); ImageStatistics stats = plot.setHistogram(imp, entireStack(imp)); if (ip.getBitDepth()!=8 && entireStack(imp)) ip.setMinAndMax(stats.min, stats.max); updateScrollBars(); if (Recorder.record) { if (Recorder.scriptMode()) Recorder.recordCall("IJ.resetThreshold(imp);"); else Recorder.record("resetThreshold"); } }
/** * Using 4 connectivity should result in five connected components. */ @Test public void testFloodFillComponentsLabeling_C4_Byte() { ByteProcessor image = createFiveSquaresImage(); FloodFillComponentsLabeling algo = new FloodFillComponentsLabeling(4, 8); ImageProcessor result = algo.computeLabels(image); assertEquals(8, result.getBitDepth()); assertEquals(5, result.get(7, 7)); }
/** * Default settings are 4 connectivity, 16 bits image. */ @Test public void testFloodFillComponentsLabeling_Default() { ByteProcessor image = createFiveSquaresImage(); FloodFillComponentsLabeling algo = new FloodFillComponentsLabeling(); ImageProcessor result = algo.computeLabels(image); assertEquals(16, result.getBitDepth()); assertEquals(5, result.get(7, 7)); }
/** * Using 8 connectivity should result in one connected component. */ @Test public void testFloodFillComponentsLabeling_C8_Short() { ByteProcessor image = createFiveSquaresImage(); FloodFillComponentsLabeling algo = new FloodFillComponentsLabeling(8, 16); ImageProcessor result = algo.computeLabels(image); assertEquals(16, result.getBitDepth()); assertEquals(1, result.get(7, 7)); }
public void run(String arg) { ImagePlus imp = IJ.getImage(); stackSize = imp.getStackSize(); imp.trimProcessor(); if (!showDialog(imp)) return; Roi roi = imp.getRoi(); if (roi!=null) roi.endPaste(); if (stackSize==1) Undo.setup(Undo.TRANSFORM, imp); else Undo.reset(); if (equalize) equalize(imp); else stretchHistogram(imp, saturated); if (normalize) { ImageProcessor ip = imp.getProcessor(); ip.setMinAndMax(0,ip.getBitDepth()==32?1.0:ip.maxValue()); } imp.updateAndDraw(); }
public void run(String arg) { ImagePlus imp = IJ.getImage(); stackSize = imp.getStackSize(); imp.trimProcessor(); if (!showDialog(imp)) return; Roi roi = imp.getRoi(); if (roi!=null) roi.endPaste(); if (stackSize==1) Undo.setup(Undo.TRANSFORM, imp); else Undo.reset(); if (equalize) equalize(imp); else stretchHistogram(imp, saturated); if (normalize) { ImageProcessor ip = imp.getProcessor(); ip.setMinAndMax(0,ip.getBitDepth()==32?1.0:ip.maxValue()); } imp.updateAndDraw(); }