- java.lang.Object
-
- ij.process.ImageProcessor
-
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
ByteProcessor,ColorProcessor,FloatProcessor,ShortProcessor
public abstract class ImageProcessor extends Object implements Cloneable
This abstract class is the superclass for classes that process the four data types (byte, short, float and RGB) supported by ImageJ. An ImageProcessor contains the pixel data of a 2D image and some basic methods to manipulate it.- See Also:
ByteProcessor,ShortProcessor,FloatProcessor,ColorProcessor,ImagePlus,ImageStack
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanantialiasedTextprotected ColorModelbaseCMstatic intBICUBICInterpolation methodsstatic intBILINEARInterpolation methodsstatic intBLACKValue of pixels included in masks.static intBLACK_AND_WHITE_LUTstatic intBLUR_MOREprotected byte[]bLUT1protected byte[]bLUT2protected booleanboldFontstatic intCENTER_JUSTIFYCenter justify text.protected intclipXMaxprotected intclipXMinprotected intclipYMaxprotected intclipYMinprotected ColorModelcmprotected ColorModelcm2static intCONVOLVEprotected float[]cTableprotected intcxprotected intcyprotected static IndexColorModeldefaultColorModelprotected ColordrawingColorstatic intFIND_EDGESprotected Graphics2DfmGraphicsprotected BufferedImagefmImageprotected Fontfontprotected FontMetricsfontMetricsprotected byte[]gLUT1protected byte[]gLUT2protected intheightprotected doublehistogramMaxprotected doublehistogramMinprotected inthistogramSizeprotected BufferedImageimageprotected Imageimgprotected booleaninterpolateprotected intinterpolationMethodprotected booleaninversionTestedstatic intINVERT_PROJECTIONComposite image projection modes.protected booleaninvertedLutstatic intISODATAIsodata thresholding methodstatic intISODATA2Modified isodata method used in Image/Adjust/Threshold toolprotected intjustificationstatic intLEFT_JUSTIFYLeft justify text.protected intlineWidthprotected booleanlutAnimationprotected intlutUpdateModestatic intMAXstatic intMAX_PROJECTIONComposite image projection modes.protected doublemaxThresholdstatic intMEDIAN_FILTERstatic intMINstatic intMIN_PROJECTIONComposite image projection modes.protected booleanminMaxSetprotected doubleminThresholdstatic intNEAREST_NEIGHBORInterpolation methodsprotected booleannewPixelsstatic intNO_LUT_UPDATEstatic doubleNO_THRESHOLDValue returned by getMinThreshold() when image is not thresholded.static intNONEInterpolation methodsstatic intOVER_UNDER_LUTprotected WritableRasterrasterstatic intRED_LUTstatic intRIGHT_JUSTIFYRight justify text.protected byte[]rLUT1protected byte[]rLUT2protected static Randomrndprotected introiHeightprotected introiWidthprotected introiXprotected introiYprotected SampleModelsampleModelprotected static doubleseedstatic intSET_FIRST_CHANNELComposite image projection modes.protected intsnapshotHeightprotected intsnapshotWidthprotected MemoryImageSourcesourcestatic intSUM_PROJECTIONComposite image projection modes.static intUPDATE_BLUEComposite image projection modes.static intUPDATE_GREENComposite image projection modes.static intUPDATE_REDComposite image projection modes.protected intwidthprotected intxMaxprotected intxMinprotected intyMaxprotected intyMin
-
Constructor Summary
Constructors Constructor Description ImageProcessor()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidabs()If this is a 32-bit or signed 16-bit image, performs an absolute value transform, otherwise does nothing.voidadd(double value)Adds 'value' to each pixel in the image or ROI.voidadd(int value)Adds 'value' to each pixel in the image or ROI.voidand(int value)Binary AND of each pixel in the image or ROI with 'value'.voidapplyMacro(String macro)Uses the Process/Math/Macro command to apply macro code to this image.abstract voidapplyTable(int[] lut)Transforms the image or ROI using a lookup table.voidautoThreshold()Converts the image to binary using an automatically determined threshold.ImageProcessorbin(int shrinkFactor)Returns a copy of this image that has been reduced in size using binning.voidblurGaussian(double sigma)Blurs the image by convolving with a Gaussian function.Objectclone()Returns a shallow copy of this ImageProcessor, where this image and the copy share pixel data.ImageProcessorconvertToByte(boolean doScaling)Returns an 8-bit version of this image as a ByteProcessor.ByteProcessorconvertToByteProcessor()Returns an 8-bit version of this image as a ByteProcessor.ByteProcessorconvertToByteProcessor(boolean scale)Returns an 8-bit version of this image as a ByteProcessor.ColorProcessorconvertToColorProcessor()Returns an RGB version of this image as a ColorProcessor.ImageProcessorconvertToFloat()Returns a 32-bit float version of this image as a FloatProcessor.FloatProcessorconvertToFloatProcessor()Returns a 32-bit float version of this image as a FloatProcessor.ImageProcessorconvertToRGB()Returns an RGB version of this image as a ColorProcessor.ImageProcessorconvertToShort(boolean doScaling)Returns a 16-bit version of this image as a ShortProcessor.ShortProcessorconvertToShortProcessor()Returns a 16-bit version of this image as a ShortProcessor.ShortProcessorconvertToShortProcessor(boolean scale)Returns a 16-bit version of this image as a ShortProcessor.abstract voidconvolve(float[] kernel, int kernelWidth, int kernelHeight)Performs a convolution operation using the specified kernel.abstract voidconvolve3x3(int[] kernel)Convolves the image or ROI with the specified 3x3 integer convolution kernel.abstract voidcopyBits(ImageProcessor ip, int xloc, int yloc, int mode)Copies the image contained in 'ip' to (xloc, yloc) using one of the transfer modes defined in the Blitter interface.abstract ImagecreateImage()Returns a copy of this image is the form of an AWT Image.ByteProcessorcreateMask()Returns a binary mask, or null if a threshold is not set or this is an RGB image.abstract ImageProcessorcreateProcessor(int width, int height)Returns a new, blank processor with the specified width and height.abstract ImageProcessorcrop()Returns a new processor containing an image that corresponds to the current ROI.static doublecubic(double x)abstract voiddilate()Dilates the image or ROI using a 3x3 minimum filter.voiddraw(Roi roi)Draws the specified ROI on this image using the line width and color defined by ip.setLineWidth() and ip.setColor().voiddrawDot(int xcenter, int ycenter)Draws a dot using the current line width and fill/draw value.voiddrawDot2(int x, int y)Deprecated.voiddrawLine(int x1, int y1, int x2, int y2)Draws a line from (x1,y1) to (x2,y2).voiddrawLine4(int x1, int y1, int x2, int y2)voiddrawOval(int x, int y, int width, int height)Draws an elliptical shape.voiddrawOverlay(Overlay overlay)Draws the specified Overlay on this image.abstract voiddrawPixel(int x, int y)Sets the pixel at (x,y) to the current fill/draw value.voiddrawPolygon(Polygon p)Draws a polygon.voiddrawRect(int x, int y, int width, int height)Draws a rectangle.voiddrawRoi(Roi roi)Draws the specified ROI on this image using the stroke width, stroke color and fill color defined by roi.setStrokeWidth, roi.setStrokeColor() and roi.setFillColor().voiddrawString(String s)Draws a string at the current drawing location using the current fill/draw value.voiddrawString(String s, int x, int y)Draws a string at the specified location using the current fill/draw value.voiddrawString(String s, int x, int y, Color background)Draws a string at the specified location with a filled background.abstract ImageProcessorduplicate()Returns a duplicate of this image.abstract voiderode()Erodes the image or ROI using a 3x3 maximum filter.voidexp()Performs a exponential transform on the image or ROI.voidfill()Fills the image or ROI bounding rectangle with the current fill/draw value.voidfill(Roi roi)Fills the ROI with the current fill/draw value.abstract voidfill(ImageProcessor mask)Fills pixels that are within the ROI bounding rectangle and part of the mask (i.e.voidfillColorSet(boolean set)For internal usevoidfillOutside(Roi roi)Fills outside an Roi.voidfillOval(int x, int y, int width, int height)Fills an elliptical shape.voidfillPolygon(Polygon p)Fills a polygon.voidfillRect(int x, int y, int width, int height)Fills a rectangle.booleanfillValueSet()Returns 'true' if the fill/draw value has been set in a macro.abstract voidfilter(int type)A 3x3 filter operation, where the argument (BLUR_MORE, FIND_EDGES, MEDIAN_FILTER, MIN or MAX) determines the filter type.voidfindEdges()Finds edges in the image or ROI using a Sobel operator.voidflipHorizontal()Flips the image or ROI horizontally.abstract voidflipVertical()Flips the image or ROI vertically.voidgamma(double value)Performs gamma correction of the image or ROI.abstract intget(int index)abstract intget(int x, int y)This is a faster version of getPixel() that does not do bounds checking.intgetAutoThreshold()Returns a pixel value (threshold) that can be used to divide the image into objects and background.intgetAutoThreshold(int[] histogram)This is a version of getAutoThreshold() that uses a histogram passed as an argument.abstract doublegetBackgroundValue()Returns the background fill value.intgetBestIndex(Color c)Returns the LUT index that's the best match for this color.doublegetBicubicInterpolatedPixel(double x0, double y0, ImageProcessor ip2)This method is from Chapter 16 of "Digital Image Processing: An Algorithmic Introduction Using Java" by Burger and Burge (http://www.imagingbook.com/).intgetBitDepth()Returns the bit depth, 8, 16, 24 (RGB) or 32.BufferedImagegetBufferedImage()Returns this image as a BufferedImage.float[]getCalibrationTable()Returns the calibration table or null.ColorModelgetColorModel()Returns this processor's color model.float[]getColumn(int x, int y, float[] data, int length)Returns the pixel values down the column starting at (x,y).voidgetColumn(int x, int y, int[] data, int length)Returns the pixel values down the column starting at (x,y).ColorModelgetCurrentColorModel()Returns the current color model, which may have been modified by setMinAndMax() or setThreshold().IndexColorModelgetDefaultColorModel()Returns the default grayscale IndexColorModel.abstract floatgetf(int index)abstract floatgetf(int x, int y)Returns the value of the pixel at (x,y) as a float.float[][]getFloatArray()Returns a copy of the pixel data as a 2D float array with dimensions [x=0..width-1][y=0..height-1].FontgetFont()Returns the current font.FontMetricsgetFontMetrics()Returns the current FontMetrics.abstract doublegetForegroundValue()Returns the default fill/draw value.intgetHeight()Returns the height of this image in pixels.abstract int[]getHistogram()Returns the histogram of the image or ROI.int[]getHistogram(int nBins)Returns the histogram of the image or ROI, using the specified number of bins.doublegetHistogramMax()Returns the maximum histogram value used for histograms of float images.doublegetHistogramMin()Returns the minimum histogram value used for histograms of float images.intgetHistogramSize()Returns the number of float image histogram bins.protected SampleModelgetIndexSampleModel()int[][]getIntArray()Returns a copy of the pixel data as a 2D int array with dimensions [x=0..width-1][y=0..height-1].booleangetInterpolate()Returns the value of the interpolate field.abstract doublegetInterpolatedPixel(double x, double y)Uses the current interpolation method (bilinear or bicubic) to find the pixel value at real coordinates (x,y).doublegetInterpolatedValue(double x, double y)Uses bilinear interpolation to find the pixel value at real coordinates (x,y).intgetInterpolationMethod()Returns the current interpolation method (NONE, BILINEAR or BICUBIC).static String[]getInterpolationMethods()double[]getLine(double x1, double y1, double x2, double y2)Returns an array containing the pixel values along the line starting at (x1,y1) and ending at (x2,y2).intgetLineWidth()Returns the current line width.LUTgetLut()intgetLutUpdateMode()Returns the LUT update mode, which can be RED_LUT, BLACK_AND_WHITE_LUT, OVER_UNDER_LUT or NO_LUT_UPDATE.ImageProcessorgetMask()For images with irregular ROIs, returns a mask, otherwise, returns null.byte[]getMaskArray()Returns a reference to the mask pixel array, or null if there is no mask.abstract doublegetMax()Returns the maximum displayed pixel value.doublegetMaxThreshold()Returns the upper threshold level.abstract doublegetMin()Returns the minimum displayed pixel value.doublegetMinThreshold()Returns the lower threshold level.intgetNChannels()Returns the number of color channels in the image.voidgetNeighborhood(int x, int y, double[][] arr)ExperimentalOverlaygetOverlay()abstract intgetPixel(int x, int y)Returns the value of the pixel at (x,y).int[]getPixel(int x, int y, int[] iArray)Returns the samples for the pixel at (x,y) in an int array.intgetPixelCount()abstract intgetPixelInterpolated(double x, double y)Uses the current interpolation method to find the pixel value at real coordinates (x,y).abstract ObjectgetPixels()Returns a reference to this image's pixel array.abstract ObjectgetPixelsCopy()Returns a copy of the pixel data.abstract floatgetPixelValue(int x, int y)Returns the value of the pixel at (x,y).protected intgetProgressIncrement(int w, int h)RectanglegetRoi()Returns a Rectangle that represents the current region of interest.float[]getRow(int x, int y, float[] data, int length)Returns the pixel values along the horizontal line starting at (x,y).voidgetRow(int x, int y, int[] data, int length)Returns the pixel values along the horizontal line starting at (x,y).intgetSliceNumber()Returns the current stack position (1-n) of this image.abstract ObjectgetSnapshotPixels()Returns a reference to the snapshot (undo) buffer, or null.ImageStatisticsgetStatistics()Calculates and returns complete uncalibrated (raw) statistics for this image or ROI but it is up to 70 times slower than getStats().ImageStatisticsgetStats()Calculates and returns uncalibrated statistics for this image or ROI, including histogram, area, mean, min and max, standard deviation, and mode.RectanglegetStringBounds(String s)Returns a rectangle enclosing the pixels affected by drawString assuming it is drawn at (x=0, y=0).intgetStringWidth(String s)Returns the width in pixels of the specified string, including any background space (whitespace) between the x drawing coordinate and the string, not necessarily including all whitespace at the right.protected static IndexColorModelgetThresholdColorModel(byte[] reds, byte[] greens, byte[] blues)Returns a color model based on the colors of the input from 0 to 254 (inclusive).doublegetValue(int x, int y)Returns the value of the pixel at (x,y), a calibrated value from 8-bit and 16-bit images, an intensity value from RGB images and a double value from 32-bit images.intgetWidth()Returns the width of this image in pixels.protected voidhideProgress()Deprecated.voidinsert(ImageProcessor ip, int xloc, int yloc)Inserts the image contained in 'ip' at (xloc, yloc).voidinvert()Inverts the image or ROI.voidinvertLut()Inverts the values in this image's LUT (indexed color model).booleanisBinary()Returns 'true' if this is a binary image (8-bit-image with only 0 and 255).booleanisColorLut()Returns true if this image uses a color LUT.booleanisDefaultLut()Returns true if the image is using the default grayscale LUT.booleanisGrayscale()Returns 'true' if this is an image with a grayscale LUT or an RGB image with identical red, green and blue channels.booleanisInvertedLut()Returns true if this image uses an inverting LUT that displays zero as white and 255 as black.booleanisKillable()Deprecated.booleanisPseudoColorLut()Returns true if this image uses a pseudocolor or grayscale LUT, in other words, is this an image that can be filtered.booleanisSigned16Bit()Returns 'true' if this is a signed 16-bit image.booleanisThreshold()Returns 'true' if this image is thresholded.voidlineTo(int x2, int y2)Draws a line from the current drawing location to (x2,y2).voidln()Does a natural logarithmic (base e) transform of the image or ROI.voidlog()Does a natural logarithmic (base e) transform of the image or ROI.protected voidmakeDefaultColorModel()protected StringmaskSizeError(ImageProcessor mask)voidmax(double value)Pixels greater than 'value' are set to 'value'.doublemaxValue()Returns the maximum possible pixel value.abstract voidmedianFilter()A 3x3 median filter.voidmin(double value)Pixels less than 'value' are set to 'value'.doubleminValue()Returns the minimum possible pixel value.voidmoveTo(int x, int y)Sets the current drawing location.voidmultiply(double value)Multiplies each pixel in the image or ROI by 'value'.abstract voidnoise(double standardDeviation)Adds pseudorandom, Gaussian ("normally") distributed values, with mean 0.0 and the specified standard deviation, to this image or ROI.voidor(int value)Binary OR of each pixel in the image or ROI with 'value'.voidputColumn(int x, int y, float[] data, int length)Inserts the pixels contained in 'data' into a column starting at (x,y).voidputColumn(int x, int y, int[] data, int length)Inserts the pixels contained in 'data' into a column starting at (x,y).abstract voidputPixel(int x, int y, int value)Stores the specified value at (x,y).voidputPixel(int x, int y, int[] iArray)Sets a pixel in the image using an int array of samples.abstract voidputPixelValue(int x, int y, double value)Stores the specified value at (x,y).voidputRow(int x, int y, float[] data, int length)Inserts the pixels contained in 'data' into a horizontal line starting at (x,y).voidputRow(int x, int y, int[] data, int length)Inserts the pixels contained in 'data' into a horizontal line starting at (x,y).abstract voidreset()Restores the pixel data from the snapshot (undo) buffer.abstract voidreset(ImageProcessor mask)Restores pixels from the snapshot buffer that are within the rectangular roi but not part of the mask.voidresetBinaryThreshold()Resets the threshold if minThreshold=maxThreshold and lutUpdateMode=NO_LUT_UPDATE.voidresetMinAndMax()For short and float images, recalculates the min and max image values needed to correctly display the image.voidresetRoi()Sets the ROI (Region of Interest) and clipping rectangle to the entire image.voidresetThreshold()Disables thresholding.ImageProcessorresize(int dstWidth)Returns a new ImageProcessor containing a scaled copy of this image or ROI, with the aspect ratio maintained.abstract ImageProcessorresize(int dstWidth, int dstHeight)Returns a new ImageProcessor containing a scaled copy of this image or ROI.ImageProcessorresize(int dstWidth, int dstHeight, boolean useAverging)Returns a new ImageProcessor containing a scaled copy of this image or ROI.protected ImageProcessorresizeLinearly(int width2, int height2)Use linear interpolation to resize images that have a width or height of one.abstract voidrotate(double angle)Rotates the image or selection 'angle' degrees clockwise.ImageProcessorrotateLeft()Rotates the entire image 90 degrees counter-clockwise.ImageProcessorrotateRight()Rotates the entire image 90 degrees clockwise.abstract voidscale(double xScale, double yScale)Scales the image by the specified factors.voidscaleAndSetThreshold(double lower, double upper, int lutUpdate)Set the threshold using a 0-255 range.voidset(double value)Assigns 'value' to each pixel in the image or ROI.abstract voidset(int index, int value)abstract voidset(int x, int y, int value)This is a faster version of putPixel() that does not clip out of range values and does not do bounds checking.voidsetAntialiasedText(boolean antialiasedText)Specifies whether or not text is drawn using antialiasing, which is enabled by default on macOS or when the font size is 14 or greater.voidsetAutoThreshold(int method, int lutUpdate)Automatically sets the lower and upper threshold levels, where 'method' must be ISODATA or ISODATA2 and 'lutUpdate' must be RED_LUT, BLACK_AND_WHITE_LUT, OVER_UNDER_LUT or NO_LUT_UPDATE.voidsetAutoThreshold(AutoThresholder.Method method, boolean darkBackground)voidsetAutoThreshold(AutoThresholder.Method method, boolean darkBackground, int lutUpdate)voidsetAutoThreshold(String method)Automatically sets the lower and upper threshold levels, where 'method' must be "Default", "Huang", "Intermodes", "IsoData", "IJ_IsoData", "Li", "MaxEntropy", "Mean", "MinError", "Minimum", "Moments", "Otsu", "Percentile", "RenyiEntropy", "Shanbhag", "Triangle" or "Yen".voidsetAutoThreshold(String mString, boolean darkBackground, int lutUpdate)voidsetBackgroundColor(Color color)Sets the background fill/draw color.abstract voidsetBackgroundValue(double value)Sets the background fill value used by the rotate() and scale() methods.voidsetBinaryThreshold()voidsetCalibrationTable(float[] cTable)Set a lookup table used by getPixelValue(), getLine() and convertToFloat() to calibrate pixel values.voidsetClipRect(Rectangle clipRect)Updates the clipping rectangle used by lineTo(), drawLine(), drawDot() and drawPixel().voidsetColor(double value)Sets the default fill/draw value.voidsetColor(int value)Sets the default fill/draw value.abstract voidsetColor(Color color)Sets the default fill/draw value to the pixel value closest to the specified color.voidsetColor(String color)Sets the fill/draw color, where 'color' is "white", "black", "blue", etc., or a hex value like "#ff0000".voidsetColorModel(ColorModel cm)Sets the color model.abstract voidsetf(int index, float value)abstract voidsetf(int x, int y, float value)Sets the value of the pixel at (x,y) to 'value'.voidsetFloatArray(float[][] a)Replaces the pixel data with contents of the specified 2D float array.voidsetFont(Font font)Sets the font used by drawString().voidsetFontSize(int size)Sets the size of the font used by drawString().voidsetGlobalBackgroundColor()Sets the global (Color Picker) background color as the fill/draw color.voidsetGlobalForegroundColor()Sets the global (Color Picker) foreground color as the fill/draw color.voidsetHistogramRange(double histMin, double histMax)Set the range used for histograms of float images.voidsetHistogramSize(int size)Set the number of bins to be used for histograms of float images.voidsetIntArray(int[][] a)Replaces the pixel data with contents of the specified 2D int array.voidsetInterpolate(boolean interpolate)This method has been replaced by setInterpolationMethod().voidsetInterpolationMethod(int method)Use this method to set the interpolation method (NONE, BILINEAR or BICUBIC) used by scale(), resize() and rotate().voidsetJustification(int justification)Sets the justification used by drawString(), wherejustificationis CENTER_JUSTIFY, RIGHT_JUSTIFY or LEFT_JUSTIFY.voidsetLineWidth(int width)Sets the line width used by lineTo() and drawDot().voidsetLut(LUT lut)voidsetLutAnimation(boolean lutAnimation)For 16 and 32 bit processors, set 'lutAnimation' true to have createImage() use the cached 8-bit version of the image.voidsetMask(ImageProcessor mask)Defines a byte mask that limits processing to an irregular ROI.abstract voidsetMinAndMax(double min, double max)This image will be displayed by mapping pixel values in the range min-max to screen values in the range 0-255.static voidsetOverColor(int red, int green, int blue)Sets the upper Over/Under threshold color.voidsetOverlay(Overlay overlay)This method is used to display virtual stack overlays.abstract voidsetPixels(int channelNumber, FloatProcessor fp)Sets the pixels (of one color channel for RGB images) from a FloatProcessor.abstract voidsetPixels(Object pixels)Sets a new pixel array for the image.voidsetProgressBar(ProgressBar pb)Assigns a progress bar to this processor.static voidsetRandomSeed(double randomSeed)voidsetRoi(int x, int y, int rwidth, int rheight)Defines a rectangular region of interest and sets the mask to null if this ROI is not the same size as the previous one.voidsetRoi(Roi roi)Defines a non-rectangular region of interest that will consist of a rectangular ROI and a mask.voidsetRoi(Polygon roi)Defines a polygonal region of interest that will consist of a rectangular ROI and a mask.voidsetRoi(Rectangle roi)Defines a rectangular region of interest and sets the mask to null if this ROI is not the same size as the previous one.voidsetSliceNumber(int slice)ImagePlus.setStack(n), ImageStack.getProcessor(n), VirtualStack.getProcessor(n) and the PlugInFilterRunner set the stack position using this method.voidsetSnapshotCopyMode(boolean b)The getPixelsCopy() method returns a reference to the snapshot buffer if it is not null and 'snapshotCopyMode' is true.abstract voidsetSnapshotPixels(Object pixels)Sets a new pixel array for the snapshot (undo) buffer.voidsetThreshold(double minThreshold, double maxThreshold)Sets the lower and upper threshold levels using NO_LUT_UPDATE.voidsetThreshold(double minThreshold, double maxThreshold, int lutUpdate)Sets the lower and upper threshold levels.static voidsetUnderColor(int red, int green, int blue)Set the lower Over/Under thresholding color.static voidsetUseBicubic(boolean b)abstract voidsetValue(double value)Sets the default fill/draw value.voidsharpen()Sharpens the image or ROI using a 3x3 convolution kernel.protected voidshowProgress(double percentDone)voidsmooth()Replaces each pixel with the 3x3 neighborhood mean.abstract voidsnapshot()Makes a copy of this image's pixel data that can be later restored using reset() or reset(mask).voidsqr()Performs a square transform on the image or ROI.voidsqrt()Performs a square root transform on the image or ROI.voidsubtract(double value)Subtracts 'value' from each pixel in the image or ROI.abstract voidswapPixelArrays()Swaps the pixel and snapshot (undo) buffers.abstract voidthreshold(int level)Sets pixels less than or equal to level to 0 and all other pixels to 255.voidthreshold(int level1, int level2)Sets pixels less than 'level1' or greater than 'level2' to 0 and all other pixels to 255.abstract FloatProcessortoFloat(int channelNumber, FloatProcessor fp)Returns a FloatProcessor with the image or one color channel thereof.StringtoString()Returns a string containing information about this ImageProcessor.voidtranslate(double xOffset, double yOffset)Moves the image or selection vertically or horizontally by a specified number of pixels.voidtranslate(int xOffset, int yOffset, boolean eraseBackground)Deprecated.replaced by translate(x,y)voidupdateComposite(int[] rgbPixels, int mode)This method is used by CompositeImage.updateImage() to create RGB images (for display) of a multi-channel composite images.voidxor(int value)Binary exclusive OR of each pixel in the image or ROI with 'value'.
-
-
-
Field Detail
-
BLACK
public static final int BLACK
Value of pixels included in masks.- See Also:
- Constant Field Values
-
NO_THRESHOLD
public static final double NO_THRESHOLD
Value returned by getMinThreshold() when image is not thresholded.- See Also:
isThreshold(), Constant Field Values
-
LEFT_JUSTIFY
public static final int LEFT_JUSTIFY
Left justify text.- See Also:
- Constant Field Values
-
CENTER_JUSTIFY
public static final int CENTER_JUSTIFY
Center justify text.- See Also:
- Constant Field Values
-
RIGHT_JUSTIFY
public static final int RIGHT_JUSTIFY
Right justify text.- See Also:
- Constant Field Values
-
ISODATA
public static final int ISODATA
Isodata thresholding method- See Also:
- Constant Field Values
-
ISODATA2
public static final int ISODATA2
Modified isodata method used in Image/Adjust/Threshold tool- See Also:
- Constant Field Values
-
UPDATE_RED
public static final int UPDATE_RED
Composite image projection modes.- See Also:
- Constant Field Values
-
UPDATE_GREEN
public static final int UPDATE_GREEN
Composite image projection modes.- See Also:
- Constant Field Values
-
UPDATE_BLUE
public static final int UPDATE_BLUE
Composite image projection modes.- See Also:
- Constant Field Values
-
SET_FIRST_CHANNEL
public static final int SET_FIRST_CHANNEL
Composite image projection modes.- See Also:
- Constant Field Values
-
SUM_PROJECTION
public static final int SUM_PROJECTION
Composite image projection modes.- See Also:
- Constant Field Values
-
MAX_PROJECTION
public static final int MAX_PROJECTION
Composite image projection modes.- See Also:
- Constant Field Values
-
MIN_PROJECTION
public static final int MIN_PROJECTION
Composite image projection modes.- See Also:
- Constant Field Values
-
INVERT_PROJECTION
public static final int INVERT_PROJECTION
Composite image projection modes.- See Also:
- Constant Field Values
-
NEAREST_NEIGHBOR
public static final int NEAREST_NEIGHBOR
Interpolation methods- See Also:
- Constant Field Values
-
NONE
public static final int NONE
Interpolation methods- See Also:
- Constant Field Values
-
BILINEAR
public static final int BILINEAR
Interpolation methods- See Also:
- Constant Field Values
-
BICUBIC
public static final int BICUBIC
Interpolation methods- See Also:
- Constant Field Values
-
BLUR_MORE
public static final int BLUR_MORE
- See Also:
- Constant Field Values
-
FIND_EDGES
public static final int FIND_EDGES
- See Also:
- Constant Field Values
-
MEDIAN_FILTER
public static final int MEDIAN_FILTER
- See Also:
- Constant Field Values
-
MIN
public static final int MIN
- See Also:
- Constant Field Values
-
MAX
public static final int MAX
- See Also:
- Constant Field Values
-
CONVOLVE
public static final int CONVOLVE
- See Also:
- Constant Field Values
-
RED_LUT
public static final int RED_LUT
- See Also:
- Constant Field Values
-
BLACK_AND_WHITE_LUT
public static final int BLACK_AND_WHITE_LUT
- See Also:
- Constant Field Values
-
NO_LUT_UPDATE
public static final int NO_LUT_UPDATE
- See Also:
- Constant Field Values
-
OVER_UNDER_LUT
public static final int OVER_UNDER_LUT
- See Also:
- Constant Field Values
-
lineWidth
protected int lineWidth
-
cx
protected int cx
-
cy
protected int cy
-
font
protected Font font
-
fontMetrics
protected FontMetrics fontMetrics
-
antialiasedText
protected boolean antialiasedText
-
boldFont
protected boolean boldFont
-
width
protected int width
-
snapshotWidth
protected int snapshotWidth
-
height
protected int height
-
snapshotHeight
protected int snapshotHeight
-
roiX
protected int roiX
-
roiY
protected int roiY
-
roiWidth
protected int roiWidth
-
roiHeight
protected int roiHeight
-
xMin
protected int xMin
-
xMax
protected int xMax
-
yMin
protected int yMin
-
yMax
protected int yMax
-
baseCM
protected ColorModel baseCM
-
cm
protected ColorModel cm
-
rLUT1
protected byte[] rLUT1
-
gLUT1
protected byte[] gLUT1
-
bLUT1
protected byte[] bLUT1
-
rLUT2
protected byte[] rLUT2
-
gLUT2
protected byte[] gLUT2
-
bLUT2
protected byte[] bLUT2
-
interpolate
protected boolean interpolate
-
interpolationMethod
protected int interpolationMethod
-
minThreshold
protected double minThreshold
-
maxThreshold
protected double maxThreshold
-
histogramSize
protected int histogramSize
-
histogramMin
protected double histogramMin
-
histogramMax
protected double histogramMax
-
cTable
protected float[] cTable
-
lutAnimation
protected boolean lutAnimation
-
source
protected MemoryImageSource source
-
img
protected Image img
-
newPixels
protected boolean newPixels
-
drawingColor
protected Color drawingColor
-
clipXMin
protected int clipXMin
-
clipXMax
protected int clipXMax
-
clipYMin
protected int clipYMin
-
clipYMax
protected int clipYMax
-
justification
protected int justification
-
lutUpdateMode
protected int lutUpdateMode
-
raster
protected WritableRaster raster
-
image
protected BufferedImage image
-
fmImage
protected BufferedImage fmImage
-
fmGraphics
protected Graphics2D fmGraphics
-
cm2
protected ColorModel cm2
-
sampleModel
protected SampleModel sampleModel
-
defaultColorModel
protected static IndexColorModel defaultColorModel
-
minMaxSet
protected boolean minMaxSet
-
seed
protected static double seed
-
rnd
protected static Random rnd
-
inversionTested
protected boolean inversionTested
-
invertedLut
protected boolean invertedLut
-
-
Method Detail
-
showProgress
protected void showProgress(double percentDone)
-
hideProgress
protected void hideProgress()
Deprecated.
-
getWidth
public int getWidth()
Returns the width of this image in pixels.
-
getHeight
public int getHeight()
Returns the height of this image in pixels.
-
getBitDepth
public int getBitDepth()
Returns the bit depth, 8, 16, 24 (RGB) or 32. RGB images actually use 32 bits per pixel.
-
getColorModel
public ColorModel getColorModel()
Returns this processor's color model. For non-RGB processors, this is the base lookup table (LUT), not the one that may have been modified by setMinAndMax() or setThreshold().
-
getCurrentColorModel
public ColorModel getCurrentColorModel()
Returns the current color model, which may have been modified by setMinAndMax() or setThreshold().
-
setColorModel
public void setColorModel(ColorModel cm)
Sets the color model. Must be an IndexColorModel (aka LUT) for all processors except the ColorProcessor.
-
getLut
public LUT getLut()
-
setLut
public void setLut(LUT lut)
-
makeDefaultColorModel
protected void makeDefaultColorModel()
-
invertLut
public void invertLut()
Inverts the values in this image's LUT (indexed color model). Does nothing if this is a ColorProcessor.
-
getBestIndex
public int getBestIndex(Color c)
Returns the LUT index that's the best match for this color.
-
isInvertedLut
public boolean isInvertedLut()
Returns true if this image uses an inverting LUT that displays zero as white and 255 as black.
-
isGrayscale
public boolean isGrayscale()
Returns 'true' if this is an image with a grayscale LUT or an RGB image with identical red, green and blue channels.
-
isColorLut
public boolean isColorLut()
Returns true if this image uses a color LUT.
-
isPseudoColorLut
public boolean isPseudoColorLut()
Returns true if this image uses a pseudocolor or grayscale LUT, in other words, is this an image that can be filtered.
-
isDefaultLut
public boolean isDefaultLut()
Returns true if the image is using the default grayscale LUT.
-
setColor
public abstract void setColor(Color color)
Sets the default fill/draw value to the pixel value closest to the specified color.
-
setColor
public void setColor(String color)
Sets the fill/draw color, where 'color' is "white", "black", "blue", etc., or a hex value like "#ff0000".
-
setBackgroundColor
public void setBackgroundColor(Color color)
Sets the background fill/draw color.
-
setColor
public void setColor(int value)
Sets the default fill/draw value.
-
setColor
public void setColor(double value)
Sets the default fill/draw value.
-
setValue
public abstract void setValue(double value)
Sets the default fill/draw value.
-
getForegroundValue
public abstract double getForegroundValue()
Returns the default fill/draw value.
-
fillValueSet
public boolean fillValueSet()
Returns 'true' if the fill/draw value has been set in a macro.
-
setBackgroundValue
public abstract void setBackgroundValue(double value)
Sets the background fill value used by the rotate() and scale() methods.
-
getBackgroundValue
public abstract double getBackgroundValue()
Returns the background fill value.
-
setGlobalForegroundColor
public void setGlobalForegroundColor()
Sets the global (Color Picker) foreground color as the fill/draw color.
-
setGlobalBackgroundColor
public void setGlobalBackgroundColor()
Sets the global (Color Picker) background color as the fill/draw color.
-
getMin
public abstract double getMin()
Returns the minimum displayed pixel value.
-
getMax
public abstract double getMax()
Returns the maximum displayed pixel value.
-
setMinAndMax
public abstract void setMinAndMax(double min, double max)This image will be displayed by mapping pixel values in the range min-max to screen values in the range 0-255. For byte images, this mapping is done by updating the LUT. For short and float images, it's done by generating 8-bit AWT images. For RGB images, it's done by changing the pixel values. With signed 16-bit images, use IJ.setMinAndMax(imp,min,max).
-
resetMinAndMax
public void resetMinAndMax()
For short and float images, recalculates the min and max image values needed to correctly display the image. For ByteProcessors, resets the LUT.
-
setThreshold
public void setThreshold(double minThreshold, double maxThreshold)Sets the lower and upper threshold levels using NO_LUT_UPDATE.
-
setThreshold
public void setThreshold(double minThreshold, double maxThreshold, int lutUpdate)Sets the lower and upper threshold levels. The 'lutUpdate' argument can be RED_LUT, BLACK_AND_WHITE_LUT, OVER_UNDER_LUT or NO_LUT_UPDATE. Thresholding of RGB images is not supported.
-
setAutoThreshold
public void setAutoThreshold(String method)
Automatically sets the lower and upper threshold levels, where 'method' must be "Default", "Huang", "Intermodes", "IsoData", "IJ_IsoData", "Li", "MaxEntropy", "Mean", "MinError", "Minimum", "Moments", "Otsu", "Percentile", "RenyiEntropy", "Shanbhag", "Triangle" or "Yen". The 'method' string may also include the keywords 'dark' (dark background) 'red' (red LUT, the default), 'b&w' (black and white LUT), 'over/under' (over/under LUT) or 'no-lut' (no LUT changes), for example "Huang dark b&w". The display range of 16-bit and 32-bit images is not reset if the 'method' string contains 'no-reset'.- See Also:
resetThreshold(),setThreshold(double, double),createMask()
-
setAutoThreshold
public void setAutoThreshold(String mString, boolean darkBackground, int lutUpdate)
-
setAutoThreshold
public void setAutoThreshold(AutoThresholder.Method method, boolean darkBackground)
-
setAutoThreshold
public void setAutoThreshold(AutoThresholder.Method method, boolean darkBackground, int lutUpdate)
-
setAutoThreshold
public void setAutoThreshold(int method, int lutUpdate)Automatically sets the lower and upper threshold levels, where 'method' must be ISODATA or ISODATA2 and 'lutUpdate' must be RED_LUT, BLACK_AND_WHITE_LUT, OVER_UNDER_LUT or NO_LUT_UPDATE.
-
scaleAndSetThreshold
public void scaleAndSetThreshold(double lower, double upper, int lutUpdate)Set the threshold using a 0-255 range. For 16-bit and 32-bit images, this range is taken as relative with respect to the range between the current display min and max, but lower=0 and upper=255 are set to the full-range limits of 16-bit images and -/+1e30 for float images.
-
resetThreshold
public void resetThreshold()
Disables thresholding.
-
getMinThreshold
public double getMinThreshold()
Returns the lower threshold level. Returns NO_THRESHOLD if thresholding is not enabled.- See Also:
isThreshold(),ImagePlus.isThreshold()
-
getMaxThreshold
public double getMaxThreshold()
Returns the upper threshold level.
-
isThreshold
public boolean isThreshold()
Returns 'true' if this image is thresholded.- See Also:
ImagePlus.isThreshold()
-
getLutUpdateMode
public int getLutUpdateMode()
Returns the LUT update mode, which can be RED_LUT, BLACK_AND_WHITE_LUT, OVER_UNDER_LUT or NO_LUT_UPDATE.
-
setBinaryThreshold
public void setBinaryThreshold()
-
resetBinaryThreshold
public void resetBinaryThreshold()
Resets the threshold if minThreshold=maxThreshold and lutUpdateMode=NO_LUT_UPDATE. This removes the invisible threshold set by the MakeBinary and Convert to Mask commands.- See Also:
setBinaryThreshold()
-
setRoi
public void setRoi(Rectangle roi)
Defines a rectangular region of interest and sets the mask to null if this ROI is not the same size as the previous one.- See Also:
resetRoi()
-
setRoi
public void setRoi(int x, int y, int rwidth, int rheight)Defines a rectangular region of interest and sets the mask to null if this ROI is not the same size as the previous one.- See Also:
resetRoi()
-
setRoi
public void setRoi(Roi roi)
Defines a non-rectangular region of interest that will consist of a rectangular ROI and a mask. After processing, callreset(mask)to restore non-masked pixels. Here is an example:ip.setRoi(new OvalRoi(50, 50, 100, 50)); ip.fill(); ip.reset(ip.getMask());The example assumessnapshot()has been called, which is the case for code executed in therun()method of plugins that implement thePlugInFilterinterface.- See Also:
ImagePlus.getRoi()
-
setRoi
public void setRoi(Polygon roi)
Defines a polygonal region of interest that will consist of a rectangular ROI and a mask. After processing, callreset(mask)to restore non-masked pixels. Here is an example:Polygon p = new Polygon(); p.addPoint(50, 0); p.addPoint(100, 100); p.addPoint(0, 100); ip.setRoi(triangle); ip.invert(); ip.reset(ip.getMask());The example assumessnapshot()has been called, which is the case for code executed in therun()method of plugins that implement thePlugInFilterinterface.
-
resetRoi
public void resetRoi()
Sets the ROI (Region of Interest) and clipping rectangle to the entire image.
-
getRoi
public Rectangle getRoi()
Returns a Rectangle that represents the current region of interest.
-
setMask
public void setMask(ImageProcessor mask)
Defines a byte mask that limits processing to an irregular ROI. Background pixels in the mask have a value of zero.
-
getMask
public ImageProcessor getMask()
For images with irregular ROIs, returns a mask, otherwise, returns null. Pixels outside the mask have a value of zero.
-
getMaskArray
public byte[] getMaskArray()
Returns a reference to the mask pixel array, or null if there is no mask.
-
setProgressBar
public void setProgressBar(ProgressBar pb)
Assigns a progress bar to this processor. Set 'pb' to null to disable the progress bar.
-
setInterpolate
public void setInterpolate(boolean interpolate)
This method has been replaced by setInterpolationMethod().
-
setInterpolationMethod
public void setInterpolationMethod(int method)
Use this method to set the interpolation method (NONE, BILINEAR or BICUBIC) used by scale(), resize() and rotate().
-
getInterpolationMethod
public int getInterpolationMethod()
Returns the current interpolation method (NONE, BILINEAR or BICUBIC).
-
getInterpolationMethods
public static String[] getInterpolationMethods()
-
getInterpolate
public boolean getInterpolate()
Returns the value of the interpolate field.
-
isKillable
public boolean isKillable()
Deprecated.
-
getLine
public double[] getLine(double x1, double y1, double x2, double y2)Returns an array containing the pixel values along the line starting at (x1,y1) and ending at (x2,y2). Pixel values are sampled using getInterpolatedValue(double,double) if interpolation is enabled or getPixelValue(int,int) if it is not. For byte and short images, returns calibrated values if a calibration table has been set using setCalibrationTable(). The length of the returned array, minus one, is approximately equal to the length of the line.
-
getRow
public void getRow(int x, int y, int[] data, int length)Returns the pixel values along the horizontal line starting at (x,y).
-
getRow
public float[] getRow(int x, int y, float[] data, int length)Returns the pixel values along the horizontal line starting at (x,y).
-
getColumn
public void getColumn(int x, int y, int[] data, int length)Returns the pixel values down the column starting at (x,y).
-
getColumn
public float[] getColumn(int x, int y, float[] data, int length)Returns the pixel values down the column starting at (x,y).
-
putRow
public void putRow(int x, int y, int[] data, int length)Inserts the pixels contained in 'data' into a horizontal line starting at (x,y).
-
putRow
public void putRow(int x, int y, float[] data, int length)Inserts the pixels contained in 'data' into a horizontal line starting at (x,y).
-
putColumn
public void putColumn(int x, int y, int[] data, int length)Inserts the pixels contained in 'data' into a column starting at (x,y).
-
putColumn
public void putColumn(int x, int y, float[] data, int length)Inserts the pixels contained in 'data' into a column starting at (x,y).
-
moveTo
public void moveTo(int x, int y)Sets the current drawing location.- See Also:
lineTo(int, int),drawString(java.lang.String)
-
setLineWidth
public void setLineWidth(int width)
Sets the line width used by lineTo() and drawDot().
-
getLineWidth
public int getLineWidth()
Returns the current line width.
-
lineTo
public void lineTo(int x2, int y2)Draws a line from the current drawing location to (x2,y2).
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2)Draws a line from (x1,y1) to (x2,y2).
-
drawLine4
public void drawLine4(int x1, int y1, int x2, int y2)
-
drawRect
public void drawRect(int x, int y, int width, int height)Draws a rectangle.
-
fillRect
public void fillRect(int x, int y, int width, int height)Fills a rectangle.
-
drawOval
public void drawOval(int x, int y, int width, int height)Draws an elliptical shape.
-
fillOval
public void fillOval(int x, int y, int width, int height)Fills an elliptical shape.
-
drawPolygon
public void drawPolygon(Polygon p)
Draws a polygon.
-
fillPolygon
public void fillPolygon(Polygon p)
Fills a polygon.
-
drawDot2
public void drawDot2(int x, int y)Deprecated.
-
drawDot
public void drawDot(int xcenter, int ycenter)Draws a dot using the current line width and fill/draw value.
-
drawString
public void drawString(String s)
Draws a string at the current drawing location using the current fill/draw value. Draws multiple lines if the string contains newline characters. The current x coordinate is the left/center/right end of the string for left/center/right justification. The current y coordinate determines the bottommost position of the string, including the descent of the font (i.e., characters reaching below the baseline) For multi-line strings, the y coordinate applies to the first line. The y of the drawing position is incremented by the height of one text line, i.e. points at the drawing position for the next text line
-
drawString
public void drawString(String s, int x, int y)
Draws a string at the specified location using the current fill/draw value. Draws multiple lines if the string contains newline characters. The x coordinate is the left/center/right end of the string for left/center/right justification. The y coordinate determines the bottommost position of the string, including the descent of the font (i.e., characters reaching below the baseline) For multi-line strings, the y coordinate applies to the first line.
-
drawString
public void drawString(String s, int x, int y, Color background)
Draws a string at the specified location with a filled background. A JavaScript example is available at http://wsr.imagej.net/macros/js/DrawTextWithBackground.js
-
setJustification
public void setJustification(int justification)
Sets the justification used by drawString(), wherejustificationis CENTER_JUSTIFY, RIGHT_JUSTIFY or LEFT_JUSTIFY. The default is LEFT_JUSTIFY.
-
setFont
public void setFont(Font font)
Sets the font used by drawString().
-
setFontSize
public void setFontSize(int size)
Sets the size of the font used by drawString().
-
setAntialiasedText
public void setAntialiasedText(boolean antialiasedText)
Specifies whether or not text is drawn using antialiasing, which is enabled by default on macOS or when the font size is 14 or greater. Antialiased text requires an 8 bit or RGB image. Antialiasing does not work with 8-bit images that are not using 0-255 display range.
-
getStringWidth
public int getStringWidth(String s)
Returns the width in pixels of the specified string, including any background space (whitespace) between the x drawing coordinate and the string, not necessarily including all whitespace at the right.
-
getStringBounds
public Rectangle getStringBounds(String s)
Returns a rectangle enclosing the pixels affected by drawString assuming it is drawn at (x=0, y=0). As drawString draws above the drawing location, the y coordinate of the rectangle is negative.
-
getFont
public Font getFont()
Returns the current font.
-
getFontMetrics
public FontMetrics getFontMetrics()
Returns the current FontMetrics.
-
smooth
public void smooth()
Replaces each pixel with the 3x3 neighborhood mean.
-
sharpen
public void sharpen()
Sharpens the image or ROI using a 3x3 convolution kernel.
-
findEdges
public void findEdges()
Finds edges in the image or ROI using a Sobel operator.
-
flipVertical
public abstract void flipVertical()
Flips the image or ROI vertically.
-
flipHorizontal
public void flipHorizontal()
Flips the image or ROI horizontally.
-
rotateRight
public ImageProcessor rotateRight()
Rotates the entire image 90 degrees clockwise. Returns a new ImageProcessor that represents the rotated image.
-
rotateLeft
public ImageProcessor rotateLeft()
Rotates the entire image 90 degrees counter-clockwise. Returns a new ImageProcessor that represents the rotated image.
-
insert
public void insert(ImageProcessor ip, int xloc, int yloc)
Inserts the image contained in 'ip' at (xloc, yloc).
-
toString
public String toString()
Returns a string containing information about this ImageProcessor.
-
fill
public void fill()
Fills the image or ROI bounding rectangle with the current fill/draw value. Use fill(Roi) or fill(ip.getMask()) to fill non-rectangular selections.- See Also:
setColor(Color),setValue(double),fill(Roi)
-
fill
public abstract void fill(ImageProcessor mask)
Fills pixels that are within the ROI bounding rectangle and part of the mask (i.e. pixels that have a value=BLACK in the mask array). Use ip.getMask() to acquire the mask. Throws and IllegalArgumentException if the mask is null or the size of the mask is not the same as the size of the ROI.- See Also:
setColor(Color),setValue(double),getMask(),fill(Roi)
-
fill
public void fill(Roi roi)
Fills the ROI with the current fill/draw value.- See Also:
setColor(Color),setValue(double),fill(Roi)
-
fillOutside
public void fillOutside(Roi roi)
Fills outside an Roi.
-
draw
public void draw(Roi roi)
Draws the specified ROI on this image using the line width and color defined by ip.setLineWidth() and ip.setColor().- See Also:
drawRoi(ij.gui.Roi)
-
drawRoi
public void drawRoi(Roi roi)
Draws the specified ROI on this image using the stroke width, stroke color and fill color defined by roi.setStrokeWidth, roi.setStrokeColor() and roi.setFillColor(). Works with RGB images. Does not work with 16-bit and float images.- See Also:
draw(ij.gui.Roi),drawOverlay(ij.gui.Overlay)
-
drawOverlay
public void drawOverlay(Overlay overlay)
Draws the specified Overlay on this image. Works best with RGB images. Does not work with 16-bit and float images. Requires Java 1.6.- See Also:
drawRoi(ij.gui.Roi)
-
setCalibrationTable
public void setCalibrationTable(float[] cTable)
Set a lookup table used by getPixelValue(), getLine() and convertToFloat() to calibrate pixel values. The length of the table must be 256 for byte images and 65536 for short images. RGB and float processors do not do calibration.
-
getCalibrationTable
public float[] getCalibrationTable()
Returns the calibration table or null.
-
setHistogramSize
public void setHistogramSize(int size)
Set the number of bins to be used for histograms of float images.
-
getHistogramSize
public int getHistogramSize()
Returns the number of float image histogram bins. The bin count is fixed at 256 for the other three data types.
-
setHistogramRange
public void setHistogramRange(double histMin, double histMax)Set the range used for histograms of float images. The image range is used if bothhistMinandhistMaxare zero.
-
getHistogramMin
public double getHistogramMin()
Returns the minimum histogram value used for histograms of float images.
-
getHistogramMax
public double getHistogramMax()
Returns the maximum histogram value used for histograms of float images.
-
getPixels
public abstract Object getPixels()
Returns a reference to this image's pixel array. The array type (byte[], short[], float[] or int[]) varies depending on the image type.
-
getPixelsCopy
public abstract Object getPixelsCopy()
Returns a copy of the pixel data. Or returns a reference to the snapshot buffer if it is not null and 'snapshotCopyMode' is true.- See Also:
snapshot(),setSnapshotCopyMode(boolean)
-
getPixel
public abstract int getPixel(int x, int y)Returns the value of the pixel at (x,y). For RGB images, the argb values are packed in an int. For float images, the the value must be converted using Float.intBitsToFloat(). Returns zero if either the x or y coodinate is out of range. Use getValue(x,y) to get calibrated values from 8-bit and 16-bit images, to get intensity values from RGB images and to get float values from 32-bit images.- See Also:
getValue(int, int)
-
get
public abstract int get(int x, int y)This is a faster version of getPixel() that does not do bounds checking.
-
get
public abstract int get(int index)
-
set
public abstract void set(int x, int y, int value)This is a faster version of putPixel() that does not clip out of range values and does not do bounds checking.
-
set
public abstract void set(int index, int value)
-
getf
public abstract float getf(int x, int y)Returns the value of the pixel at (x,y) as a float. Faster than getPixelValue() but does no bounds checking and does not return calibrated values.
-
getf
public abstract float getf(int index)
-
setf
public abstract void setf(int x, int y, float value)Sets the value of the pixel at (x,y) to 'value'. Does no bounds checking or clamping, making it faster than putPixel(). Due to the lack of bounds checking, (x,y) coordinates outside the image may cause an exception. Due to the lack of clamping, values outside the 0-255 range (for byte) or 0-65535 range (for short) are not handled correctly.
-
setf
public abstract void setf(int index, float value)
-
getPixelCount
public int getPixelCount()
-
getIntArray
public int[][] getIntArray()
Returns a copy of the pixel data as a 2D int array with dimensions [x=0..width-1][y=0..height-1]. With RGB images, the returned values are in packed ARGB format. With float images, the returned values must be converted to float using Float.intBitsToFloat().
-
setIntArray
public void setIntArray(int[][] a)
Replaces the pixel data with contents of the specified 2D int array.
-
getFloatArray
public float[][] getFloatArray()
Returns a copy of the pixel data as a 2D float array with dimensions [x=0..width-1][y=0..height-1].
-
setFloatArray
public void setFloatArray(float[][] a)
Replaces the pixel data with contents of the specified 2D float array.
-
getNeighborhood
public void getNeighborhood(int x, int y, double[][] arr)Experimental
-
getPixel
public int[] getPixel(int x, int y, int[] iArray)Returns the samples for the pixel at (x,y) in an int array. RGB pixels have three samples, all others have one. Returns zeros if the the coordinates are not in bounds. iArray is an optional preallocated array.
-
putPixel
public void putPixel(int x, int y, int[] iArray)Sets a pixel in the image using an int array of samples. RGB pixels have three samples, all others have one.
-
getInterpolatedPixel
public abstract double getInterpolatedPixel(double x, double y)Uses the current interpolation method (bilinear or bicubic) to find the pixel value at real coordinates (x,y).
-
getPixelInterpolated
public abstract int getPixelInterpolated(double x, double y)Uses the current interpolation method to find the pixel value at real coordinates (x,y). For RGB images, the argb values are packed in an int. For float images, the value must be converted using Float.intBitsToFloat(). Returns zero if the (x, y) is not inside the image.
-
getInterpolatedValue
public final double getInterpolatedValue(double x, double y)Uses bilinear interpolation to find the pixel value at real coordinates (x,y). Returns zero if the (x, y) is not inside the image.
-
getBicubicInterpolatedPixel
public double getBicubicInterpolatedPixel(double x0, double y0, ImageProcessor ip2)This method is from Chapter 16 of "Digital Image Processing: An Algorithmic Introduction Using Java" by Burger and Burge (http://www.imagingbook.com/).
-
cubic
public static final double cubic(double x)
-
putPixel
public abstract void putPixel(int x, int y, int value)Stores the specified value at (x,y). Does nothing if (x,y) is outside the image boundary. For 8-bit and 16-bit images, out of range values are clamped. For RGB images, the argb values are packed in 'value'. For float images, 'value' is expected to be a float converted to an int using Float.floatToIntBits().
-
getValue
public double getValue(int x, int y)Returns the value of the pixel at (x,y), a calibrated value from 8-bit and 16-bit images, an intensity value from RGB images and a double value from 32-bit images. This is an alias for getPixelValue(x,y).- See Also:
getPixel(int, int),getPixelValue(int, int),getf(int, int)
-
getPixelValue
public abstract float getPixelValue(int x, int y)Returns the value of the pixel at (x,y). For byte and short images, returns a calibrated value if a calibration table has been set using setCalibraionTable(). For RGB images, returns the luminance value.- See Also:
getPixel(int, int),getValue(int, int),getf(int, int)
-
putPixelValue
public abstract void putPixelValue(int x, int y, double value)Stores the specified value at (x,y).
-
drawPixel
public abstract void drawPixel(int x, int y)Sets the pixel at (x,y) to the current fill/draw value.
-
setPixels
public abstract void setPixels(Object pixels)
Sets a new pixel array for the image. The length of the array must be equal to width*height. Use setSnapshotPixels(null) to clear the snapshot buffer.
-
copyBits
public abstract void copyBits(ImageProcessor ip, int xloc, int yloc, int mode)
Copies the image contained in 'ip' to (xloc, yloc) using one of the transfer modes defined in the Blitter interface.
-
applyTable
public abstract void applyTable(int[] lut)
Transforms the image or ROI using a lookup table. The length of the table must be 256 for byte images and 65536 for short images. RGB and float images are not supported.
-
invert
public void invert()
Inverts the image or ROI.With 8-bit images, p=255-p.
With RGB images, converts each pixel to three 8-bit pixels and uses p=255-p.
With 16-bit images, p=65535-p, or p=255-p, p=1024-p, etc. if an "Unsigned 16-bit range" is set using the "Set" option of the Image>Adjust>Brightness/Contrast dialog.
With 32-bit images, p=max-(p-min), where 'min' and 'max' are the minimum and maximum displayed pixel values.
-
add
public void add(int value)
Adds 'value' to each pixel in the image or ROI.
-
add
public void add(double value)
Adds 'value' to each pixel in the image or ROI.
-
subtract
public void subtract(double value)
Subtracts 'value' from each pixel in the image or ROI.
-
multiply
public void multiply(double value)
Multiplies each pixel in the image or ROI by 'value'.
-
set
public void set(double value)
Assigns 'value' to each pixel in the image or ROI.
-
and
public void and(int value)
Binary AND of each pixel in the image or ROI with 'value'.
-
or
public void or(int value)
Binary OR of each pixel in the image or ROI with 'value'.
-
xor
public void xor(int value)
Binary exclusive OR of each pixel in the image or ROI with 'value'.
-
gamma
public void gamma(double value)
Performs gamma correction of the image or ROI.
-
log
public void log()
Does a natural logarithmic (base e) transform of the image or ROI.
-
ln
public void ln()
Does a natural logarithmic (base e) transform of the image or ROI.
-
exp
public void exp()
Performs a exponential transform on the image or ROI.
-
sqr
public void sqr()
Performs a square transform on the image or ROI.
-
sqrt
public void sqrt()
Performs a square root transform on the image or ROI.
-
abs
public void abs()
If this is a 32-bit or signed 16-bit image, performs an absolute value transform, otherwise does nothing.
-
min
public void min(double value)
Pixels less than 'value' are set to 'value'.
-
max
public void max(double value)
Pixels greater than 'value' are set to 'value'.
-
createImage
public abstract Image createImage()
Returns a copy of this image is the form of an AWT Image.
-
getBufferedImage
public BufferedImage getBufferedImage()
Returns this image as a BufferedImage.
-
createProcessor
public abstract ImageProcessor createProcessor(int width, int height)
Returns a new, blank processor with the specified width and height.
-
snapshot
public abstract void snapshot()
Makes a copy of this image's pixel data that can be later restored using reset() or reset(mask).- See Also:
reset(),reset(ImageProcessor)
-
reset
public abstract void reset()
Restores the pixel data from the snapshot (undo) buffer.
-
swapPixelArrays
public abstract void swapPixelArrays()
Swaps the pixel and snapshot (undo) buffers.
-
reset
public abstract void reset(ImageProcessor mask)
Restores pixels from the snapshot buffer that are within the rectangular roi but not part of the mask.
-
setSnapshotPixels
public abstract void setSnapshotPixels(Object pixels)
Sets a new pixel array for the snapshot (undo) buffer.
-
getSnapshotPixels
public abstract Object getSnapshotPixels()
Returns a reference to the snapshot (undo) buffer, or null.
-
convolve3x3
public abstract void convolve3x3(int[] kernel)
Convolves the image or ROI with the specified 3x3 integer convolution kernel.
-
filter
public abstract void filter(int type)
A 3x3 filter operation, where the argument (BLUR_MORE, FIND_EDGES, MEDIAN_FILTER, MIN or MAX) determines the filter type.
-
medianFilter
public abstract void medianFilter()
A 3x3 median filter. Requires 8-bit or RGB image.
-
noise
public abstract void noise(double standardDeviation)
Adds pseudorandom, Gaussian ("normally") distributed values, with mean 0.0 and the specified standard deviation, to this image or ROI.
-
crop
public abstract ImageProcessor crop()
Returns a new processor containing an image that corresponds to the current ROI.
-
threshold
public void threshold(int level1, int level2)Sets pixels less than 'level1' or greater than 'level2' to 0 and all other pixels to 255. Only works with 8-bit images.
-
threshold
public abstract void threshold(int level)
Sets pixels less than or equal to level to 0 and all other pixels to 255. Only works with 8-bit and 16-bit images.
-
duplicate
public abstract ImageProcessor duplicate()
Returns a duplicate of this image.
-
scale
public abstract void scale(double xScale, double yScale)Scales the image by the specified factors. Does not change the image size.- See Also:
setInterpolate(boolean),resize(int, int)
-
resize
public abstract ImageProcessor resize(int dstWidth, int dstHeight)
Returns a new ImageProcessor containing a scaled copy of this image or ROI.- See Also:
setInterpolate(boolean)
-
resize
public ImageProcessor resize(int dstWidth)
Returns a new ImageProcessor containing a scaled copy of this image or ROI, with the aspect ratio maintained.
-
resize
public ImageProcessor resize(int dstWidth, int dstHeight, boolean useAverging)
Returns a new ImageProcessor containing a scaled copy of this image or ROI.- Parameters:
dstWidth- Image width of the resulting ImageProcessordstHeight- Image height of the resulting ImageProcessoruseAverging- True means that the averaging occurs to avoid aliasing artifacts; the kernel shape for averaging is determined by the interpolationMethod. False if subsampling without any averaging should be used on downsizing. Has no effect on upsizing.- See Also:
Author: Michael Schmid
-
resizeLinearly
protected ImageProcessor resizeLinearly(int width2, int height2)
Use linear interpolation to resize images that have a width or height of one.
-
bin
public ImageProcessor bin(int shrinkFactor)
Returns a copy of this image that has been reduced in size using binning.
-
rotate
public abstract void rotate(double angle)
Rotates the image or selection 'angle' degrees clockwise.
-
translate
public void translate(double xOffset, double yOffset)Moves the image or selection vertically or horizontally by a specified number of pixels. Positive x values move the image or selection to the right, negative values move it to the left. Positive y values move the image or selection down, negative values move it up.
-
translate
public void translate(int xOffset, int yOffset, boolean eraseBackground)Deprecated.replaced by translate(x,y)
-
getHistogram
public abstract int[] getHistogram()
Returns the histogram of the image or ROI. Returns a luminosity histogram for RGB images and null for float images.For 8-bit and 16-bit images, returns an array with one entry for each possible value that a pixel can have, from 0 to 255 (8-bit image) or 0-65535 (16-bit image). Thus, the array size is 256 or 65536, and the bin width in uncalibrated units is 1.
For RGB images, the brightness is evaluated using the color weights (which would result in a float value) and rounded to an int. This gives 256 bins. FloatProcessor.getHistogram is not implemented (returns null).
-
getHistogram
public int[] getHistogram(int nBins)
Returns the histogram of the image or ROI, using the specified number of bins.
-
erode
public abstract void erode()
Erodes the image or ROI using a 3x3 maximum filter. Requires 8-bit or RGB image.
-
dilate
public abstract void dilate()
Dilates the image or ROI using a 3x3 minimum filter. Requires 8-bit or RGB image.
-
setLutAnimation
public void setLutAnimation(boolean lutAnimation)
For 16 and 32 bit processors, set 'lutAnimation' true to have createImage() use the cached 8-bit version of the image.
-
convertToByte
public ImageProcessor convertToByte(boolean doScaling)
Returns an 8-bit version of this image as a ByteProcessor.
-
convertToShort
public ImageProcessor convertToShort(boolean doScaling)
Returns a 16-bit version of this image as a ShortProcessor.
-
convertToFloat
public ImageProcessor convertToFloat()
Returns a 32-bit float version of this image as a FloatProcessor. For byte and short images, converts using a calibration function if a calibration table has been set using setCalibrationTable().
-
convertToRGB
public ImageProcessor convertToRGB()
Returns an RGB version of this image as a ColorProcessor.
-
convertToByteProcessor
public ByteProcessor convertToByteProcessor()
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.
-
convertToByteProcessor
public ByteProcessor convertToByteProcessor(boolean scale)
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.
-
convertToShortProcessor
public ShortProcessor convertToShortProcessor()
Returns a 16-bit version of this image as a ShortProcessor. 32-bit pixel data are scaled from min-max to 0-255.
-
convertToShortProcessor
public ShortProcessor convertToShortProcessor(boolean scale)
Returns a 16-bit version of this image as a ShortProcessor. 32-bit pixel data are scaled from min-max to 0-255 if 'scale' is true.
-
convertToFloatProcessor
public FloatProcessor convertToFloatProcessor()
Returns a 32-bit float version of this image as a FloatProcessor. For byte and short images, converts using a calibration function if a calibration table has been set using setCalibrationTable().
-
convertToColorProcessor
public ColorProcessor convertToColorProcessor()
Returns an RGB version of this image as a ColorProcessor.
-
convolve
public abstract void convolve(float[] kernel, int kernelWidth, int kernelHeight)Performs a convolution operation using the specified kernel. KernelWidth and kernelHeight must be odd.
-
autoThreshold
public void autoThreshold()
Converts the image to binary using an automatically determined threshold. For byte and short images, converts to binary using an automatically determined threshold. For RGB images, converts each channel to binary. For float images, does nothing.
-
getAutoThreshold
public int getAutoThreshold()
Returns a pixel value (threshold) that can be used to divide the image into objects and background. It does this by taking a test threshold and computing the average of the pixels at or below the threshold and pixels above. It then computes the average of those two, increments the threshold, and repeats the process. Incrementing stops when the threshold is larger than the composite average. That is, threshold = (average background + average objects)/2. This description was posted to the ImageJ mailing list by Jordan Bevic.
-
getAutoThreshold
public int getAutoThreshold(int[] histogram)
This is a version of getAutoThreshold() that uses a histogram passed as an argument.
-
setClipRect
public void setClipRect(Rectangle clipRect)
Updates the clipping rectangle used by lineTo(), drawLine(), drawDot() and drawPixel(). The clipping rectangle is reset by passing a null argument or by calling resetRoi().
-
maskSizeError
protected String maskSizeError(ImageProcessor mask)
-
getIndexSampleModel
protected SampleModel getIndexSampleModel()
-
getDefaultColorModel
public IndexColorModel getDefaultColorModel()
Returns the default grayscale IndexColorModel.
-
setSnapshotCopyMode
public void setSnapshotCopyMode(boolean b)
The getPixelsCopy() method returns a reference to the snapshot buffer if it is not null and 'snapshotCopyMode' is true.- See Also:
getPixelsCopy(),snapshot()
-
getNChannels
public int getNChannels()
Returns the number of color channels in the image. The color channels can be accessed by toFloat(channelNumber, fp) and written by setPixels(channelNumber, fp).- Returns:
- 1 for grayscale images, 3 for RGB images
-
toFloat
public abstract FloatProcessor toFloat(int channelNumber, FloatProcessor fp)
Returns a FloatProcessor with the image or one color channel thereof. The roi and mask are also set for the FloatProcessor.- Parameters:
channelNumber- Determines the color channel, 0=red, 1=green, 2=blue. Ignored for grayscale images.fp- Here a FloatProcessor can be supplied, or null. The FloatProcessor is overwritten when converting data (re-using its pixels array improves performance).- Returns:
- A FloatProcessor with the converted image data of the color channel selected
-
setPixels
public abstract void setPixels(int channelNumber, FloatProcessor fp)Sets the pixels (of one color channel for RGB images) from a FloatProcessor.- Parameters:
channelNumber- Determines the color channel, 0=red, 1=green, 2=blue.Ignored for grayscale images.fp- The FloatProcessor where the image data are read from.
-
minValue
public double minValue()
Returns the minimum possible pixel value.
-
maxValue
public double maxValue()
Returns the maximum possible pixel value.
-
updateComposite
public void updateComposite(int[] rgbPixels, int mode)This method is used by CompositeImage.updateImage() to create RGB images (for display) of a multi-channel composite images.
-
setOverColor
public static void setOverColor(int red, int green, int blue)Sets the upper Over/Under threshold color. Can be called from a macro, e.g., call("ij.process.ImageProcessor.setOverColor", 0,255,255).
-
setUnderColor
public static void setUnderColor(int red, int green, int blue)Set the lower Over/Under thresholding color.
-
isBinary
public boolean isBinary()
Returns 'true' if this is a binary image (8-bit-image with only 0 and 255).
-
isSigned16Bit
public boolean isSigned16Bit()
Returns 'true' if this is a signed 16-bit image.
-
setUseBicubic
public static void setUseBicubic(boolean b)
-
getStats
public ImageStatistics getStats()
Calculates and returns uncalibrated statistics for this image or ROI, including histogram, area, mean, min and max, standard deviation, and mode. Use the setRoi(Roi) method to limit statistics to a non-rectangular area.- Returns:
- an
ImageStatisticsobject - See Also:
setRoi(Roi),getStatistics(),ImagePlus.getStatistics()
-
getStatistics
public ImageStatistics getStatistics()
Calculates and returns complete uncalibrated (raw) statistics for this image or ROI but it is up to 70 times slower than getStats(). Use the setRoi(Roi) method to limit statistics to a non-rectangular area.- Returns:
- an
ImageStatisticsobject - See Also:
setRoi(Roi),getStats(),ImagePlus.getAllStatistics()
-
blurGaussian
public void blurGaussian(double sigma)
Blurs the image by convolving with a Gaussian function.
-
applyMacro
public void applyMacro(String macro)
Uses the Process/Math/Macro command to apply macro code to this image.
-
getSliceNumber
public int getSliceNumber()
Returns the current stack position (1-n) of this image.
-
setSliceNumber
public void setSliceNumber(int slice)
ImagePlus.setStack(n), ImageStack.getProcessor(n), VirtualStack.getProcessor(n) and the PlugInFilterRunner set the stack position using this method.
-
clone
public Object clone()
Returns a shallow copy of this ImageProcessor, where this image and the copy share pixel data. Use the duplicate() method to create a copy that does not share the pixel data.- Overrides:
clonein classObject- See Also:
duplicate()
-
setOverlay
public void setOverlay(Overlay overlay)
This method is used to display virtual stack overlays.
-
getOverlay
public Overlay getOverlay()
-
getProgressIncrement
protected int getProgressIncrement(int w, int h)
-
setRandomSeed
public static void setRandomSeed(double randomSeed)
-
createMask
public ByteProcessor createMask()
Returns a binary mask, or null if a threshold is not set or this is an RGB image.
-
getThresholdColorModel
protected static IndexColorModel getThresholdColorModel(byte[] reds, byte[] greens, byte[] blues)
Returns a color model based on the colors of the input from 0 to 254 (inclusive). Entry 255 is red, for showing the thresholded areas.
-
fillColorSet
public void fillColorSet(boolean set)
For internal use
-
-