- java.lang.Object
-
- ij.process.ImageProcessor
-
- ij.process.ColorProcessor
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
IntProcessor
public class ColorProcessor extends ImageProcessor
This is an 32-bit RGB image and methods that operate on that image.. Based on the ImageProcessor class from "KickAss Java Programming" by Tonny Espeset (1996).
-
-
Field Summary
Fields Modifier and Type Field Description protected intmaxprotected intminprotected int[]pixelsstatic intRGB_DILATEstatic intRGB_ERODEstatic intRGB_FIND_EDGESstatic intRGB_MAXstatic intRGB_MEDIANstatic intRGB_MINstatic intRGB_NOISEstatic intRGB_RESIZEstatic intRGB_ROTATEstatic intRGB_SCALEstatic intRGB_THRESHOLDstatic intRGB_TRANSLATEprotected int[]snapshotPixels-
Fields inherited from class ij.process.ImageProcessor
antialiasedText, baseCM, BICUBIC, BILINEAR, BLACK, BLACK_AND_WHITE_LUT, BLUR_MORE, bLUT1, bLUT2, boldFont, CENTER_JUSTIFY, clipXMax, clipXMin, clipYMax, clipYMin, cm, cm2, CONVOLVE, cTable, cx, cy, defaultColorModel, drawingColor, fillValueSet, FIND_EDGES, fmGraphics, fmImage, font, fontMetrics, gLUT1, gLUT2, height, histogramMax, histogramMin, histogramSize, image, img, interpolate, interpolationMethod, inversionTested, INVERT_PROJECTION, invertedLut, ISODATA, ISODATA2, justification, LEFT_JUSTIFY, lineWidth, lutAnimation, lutUpdateMode, MAX, MAX_PROJECTION, maxThreshold, MEDIAN_FILTER, MIN, MIN_PROJECTION, minMaxSet, minThreshold, NEAREST_NEIGHBOR, newPixels, NO_LUT_UPDATE, NO_THRESHOLD, NONE, OVER_UNDER_LUT, raster, RED_LUT, RIGHT_JUSTIFY, rLUT1, rLUT2, rnd, roiHeight, roiWidth, roiX, roiY, sampleModel, seed, SET_FIRST_CHANNEL, snapshotHeight, snapshotWidth, source, SUM_PROJECTION, UPDATE_BLUE, UPDATE_GREEN, UPDATE_RED, width, xMax, xMin, yMax, yMin
-
-
Constructor Summary
Constructors Constructor Description ColorProcessor(int width, int height)Creates a blank ColorProcessor of the specified dimensions.ColorProcessor(int width, int height, int[] pixels)Creates a ColorProcessor from a pixel array.ColorProcessor(java.awt.Image img)Creates a ColorProcessor from an AWT Image or BufferedImage.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyTable(int[] lut)Transforms the image or ROI using a lookup table.voidapplyTable(int[] lut, int channels)voidautoThreshold()Converts the image to binary using an automatically determined threshold.booleancaSnapshot()Used by the ContrastAdjustervoidcaSnapshot(boolean set)Used by the ContrastAdjustervoidconvolve(float[] kernel, int kernelWidth, int kernelHeight)Performs a convolution operation using the specified kernel.voidconvolve3x3(int[] kernel)3x3 convolution contributed by Glynne Casteel.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.java.awt.ImagecreateImage()Returns a copy of this image is the form of an AWT Image.ImageProcessorcreateProcessor(int width, int height)Returns a new, blank ColorProcessor with the specified width and height.ImageProcessorcrop()Returns a new processor containing an image that corresponds to the current ROI.voiddilate()Dilates the image or ROI using a 3x3 minimum filter.voiddrawPixel(int x, int y)Draws a pixel in the current foreground color.ImageProcessorduplicate()Returns a duplicate of this image.voiderode()Erodes the image or ROI using a 3x3 maximum filter.voidfill()Fills the current rectangular ROI.voidfill(ImageProcessor mask)Fills pixels that are within roi and part of the mask.voidfilter(int type)A 3x3 filter operation, where the argument (ImageProcessor.BLUR_MORE, FIND_EDGES, MEDIAN_FILTER, MIN or MAX) determines the filter type.voidfilterRGB(int type, double arg)Performs the specified filter on the red, green and blue planes of this image.voidfindEdges()Finds edges in the image or ROI using a Sobel operator.voidflipVertical()Flips the image or ROI vertically.intget(int index)intget(int x, int y)This is a faster version of getPixel() that does not do bounds checking.doublegetBackgroundValue()Returns the background fill value.intgetBestIndex(java.awt.Color c)Always returns 0 since RGB images do not use LUTs.intgetBitDepth()Returns the bit depth, 8, 16, 24 (RGB) or 32.FloatProcessorgetBrightness()Returns brightness as a FloatProcessor.byte[]getChannel(int channel)Returns the specified plane (1=red, 2=green, 3=blue, 4=alpha) as a byte array.ByteProcessorgetChannel(int channel, ByteProcessor bp)Returns the specified plane (1=red, 2=green, 3=blue, 4=alpha) as a ByteProcessor.java.awt.ColorgetColor(int x, int y)floatgetf(int index)floatgetf(int x, int y)Returns the value of the pixel at (x,y) as a float.doublegetForegroundValue()Returns the foreground fill/draw value.int[]getHistogram()Returns the histogram of the image or ROI.int[]getHistogram(ImageProcessor mask)voidgetHSB(byte[] H, byte[] S, byte[] B)Returns hue, saturation and brightness in 3 byte arrays.voidgetHSB(float[] H, float[] S, float[] B)Returns hue, saturation and brightness in 3 float arrays.ImageStackgetHSB32Stack()Returns an ImageStack with three 32-bit slices, representing hue, saturation and brightnessImageStackgetHSBStack()Returns an ImageStack with three 8-bit slices, representing hue, saturation and brightnessdoublegetInterpolatedPixel(double x, double y)Calls getPixelValue(x,y).intgetInterpolatedRGBPixel(double x, double y)Uses bilinear interpolation to find the pixel value at real coordinates (x,y).doublegetMax()Returns the largest displayed pixel value.doublegetMin()Returns the smallest displayed pixel value.intgetNChannels()Returns the number of color channels (3).intgetPixel(int x, int y)Returns the value of the pixel at (x,y).int[]getPixel(int x, int y, int[] iArray)Returns the 3 samples for the pixel at (x,y) in an array of int.intgetPixelInterpolated(double x, double y)Uses the current interpolation method to find the pixel value at real coordinates (x,y).java.lang.ObjectgetPixels()Returns a reference to the int array containing this image's pixel data.java.lang.ObjectgetPixelsCopy()Returns a copy of the pixel data.floatgetPixelValue(int x, int y)Converts the specified pixel to grayscale using the formula g=(r+g+b)/3 and returns it as a float.voidgetRGB(byte[] R, byte[] G, byte[] B)Returns the red, green and blue planes as 3 byte arrays.double[]getRGBWeights()Returns the values set by setRGBWeights(), or null if setRGBWeights() has not been called.java.lang.ObjectgetSnapshotPixels()Returns a reference to the snapshot pixel array.static double[]getWeightingFactors()Returns the three weighting factors used by getPixelValue(), getHistogram() and convertToByte() to do color conversions.voidinvertLut()Does nothing since RGB images do not use LUTs.booleanisGrayscale()Returns 'true' if this is a grayscale image.booleanisInvertedLut()Always returns false since RGB images do not use LUTs.ImageProcessormakeThumbnail(int width2, int height2, double smoothFactor)Uses averaging to creates a new ColorProcessor containing a downsized copy of this image or selection.voidmedianFilter()A 3x3 median filter.voidnoise(double range)Adds pseudorandom, Gaussian ("normally") distributed values, with mean 0.0 and the specified standard deviation, to this image or ROI.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 a 3 element (R, G and B) int array of samples.voidputPixelValue(int x, int y, double value)Stores the specified real grayscale value at (x,y).voidreset()Restores the pixel data from the snapshot (undo) buffer.voidreset(ImageProcessor mask)Restores pixels from the snapshot buffer that are within the rectangular roi but not part of the mask.ImageProcessorresize(int dstWidth, int dstHeight)Creates a new ColorProcessor containing a scaled copy of this image or selection.voidrotate(double angle)Rotates the image or ROI 'angle' degrees clockwise.voidscale(double xScale, double yScale)Scales the image or selection using the specified scale factors.voidset(int index, int value)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.voidsetBackgroundColor(java.awt.Color color)Sets the background fill/draw color.voidsetBackgroundValue(double value)Sets the background fill value, wherevalueis interpreted as an RGB int.voidsetBrightness(FloatProcessor fp)Updates the brightness using the pixels in the specified FloatProcessor).voidsetChannel(int channel, ByteProcessor bp)Sets the pixels of one color channel from a ByteProcessor.voidsetColor(int color)Sets the fill/draw color, wherecoloris an RGB int.voidsetColor(java.awt.Color color)Sets the foreground color.voidsetColorModel(java.awt.image.ColorModel cm)Sets the color model.voidsetf(int index, float value)voidsetf(int x, int y, float value)Sets the value of the pixel at (x,y) to 'value'.voidsetHSB(byte[] H, byte[] S, byte[] B)Sets the current pixels from 3 byte arrays (hue, saturation and brightness).voidsetHSB(float[] H, float[] S, float[] B)Sets the current pixels from 3 float arrays (hue, saturation and brightness).voidsetMinAndMax(double min, double max)Uses a table look-up to map the pixels in this image from min-max to 0-255.voidsetMinAndMax(double min, double max, int channels)voidsetPixels(int channelNumber, FloatProcessor fp)Sets the pixels of one color channel from a FloatProcessor.voidsetPixels(java.lang.Object pixels)Sets a new pixel array for the image.voidsetRGB(byte[] R, byte[] G, byte[] B)Sets the current pixels from 3 byte arrays (reg, green, blue).voidsetRGBWeights(double[] weights)This is a thread-safe (non-static) version of setWeightingFactors().voidsetRGBWeights(double rweight, double gweight, double bweight)This is a thread-safe (non-static) version of setWeightingFactors().voidsetSnapshotPixels(java.lang.Object pixels)Sets a new pixel array for the snapshot (undo) buffer.voidsetValue(double value)Sets the default fill/draw value, wherevalueis interpreted as an RGB int.static voidsetWeightingFactors(double rFactor, double gFactor, double bFactor)Sets the weighting factors used by getPixelValue(), getHistogram() and convertToByte() to do color conversions.voidsnapshot()Makes a copy of this image's pixel data that can be later restored using reset() or reset(mask).voidswapPixelArrays()Swaps the pixel and snapshot (undo) arrays.voidthreshold(int level)Not implemented.FloatProcessortoFloat(int channelNumber, FloatProcessor fp)Returns a FloatProcessor with one color channel of the image.voidupdateComposite(int[] rgbPixels, int channel)This method is used by CompositeImage.updateImage() to create RGB images (for display) of a multi-channel composite images.booleanweightedHistogram()-
Methods inherited from class ij.process.ImageProcessor
abs, add, add, and, applyMacro, bin, blurGaussian, clone, convertToByte, convertToByteProcessor, convertToByteProcessor, convertToColorProcessor, convertToFloat, convertToFloatProcessor, convertToRGB, convertToShort, convertToShortProcessor, convertToShortProcessor, createMask, cubic, draw, drawDot, drawDot2, drawLine, drawLine4, drawOval, drawOverlay, drawPolygon, drawRect, drawRoi, drawString, drawString, drawString, exp, fill, fillOutside, fillOval, fillPolygon, fillRect, fillValueSet, flipHorizontal, gamma, getAutoThreshold, getAutoThreshold, getBicubicInterpolatedPixel, getBufferedImage, getCalibrationTable, getColorModel, getColumn, getColumn, getCurrentColorModel, getDefaultColorModel, getFloatArray, getFont, getFontMetrics, getHeight, getHistogram, getHistogramMax, getHistogramMin, getHistogramSize, getIndexSampleModel, getIntArray, getInterpolate, getInterpolatedValue, getInterpolationMethod, getInterpolationMethods, getLine, getLineWidth, getLut, getLutUpdateMode, getMask, getMaskArray, getMaxThreshold, getMinThreshold, getNeighborhood, getOverlay, getPixelCount, getProgressIncrement, getRoi, getRow, getRow, getSliceNumber, getStatistics, getStats, getStringBounds, getStringWidth, getThresholdColorModel, getValue, getWidth, hideProgress, insert, invert, isBinary, isColorLut, isDefaultLut, isKillable, isPseudoColorLut, isSigned16Bit, isThreshold, lineTo, ln, log, makeDefaultColorModel, maskSizeError, max, maxValue, min, minValue, moveTo, multiply, or, putColumn, putColumn, putRow, putRow, resetBinaryThreshold, resetMinAndMax, resetRoi, resetThreshold, resize, resize, resizeLinearly, rotateLeft, rotateRight, scaleAndSetThreshold, set, setAntialiasedText, setAutoThreshold, setAutoThreshold, setAutoThreshold, setAutoThreshold, setAutoThreshold, setBinaryThreshold, setCalibrationTable, setClipRect, setColor, setColor, setFloatArray, setFont, setFontSize, setGlobalBackgroundColor, setGlobalForegroundColor, setHistogramRange, setHistogramSize, setIntArray, setInterpolate, setInterpolationMethod, setJustification, setLineWidth, setLut, setLutAnimation, setMask, setOverColor, setOverlay, setProgressBar, setRandomSeed, setRoi, setRoi, setRoi, setRoi, setSliceNumber, setSnapshotCopyMode, setThreshold, setThreshold, setUnderColor, setUseBicubic, sharpen, showProgress, smooth, sqr, sqrt, subtract, threshold, toString, translate, translate, xor
-
-
-
-
Field Detail
-
pixels
protected int[] pixels
-
snapshotPixels
protected int[] snapshotPixels
-
min
protected int min
-
max
protected int max
-
RGB_NOISE
public static final int RGB_NOISE
- See Also:
- Constant Field Values
-
RGB_MEDIAN
public static final int RGB_MEDIAN
- See Also:
- Constant Field Values
-
RGB_FIND_EDGES
public static final int RGB_FIND_EDGES
- See Also:
- Constant Field Values
-
RGB_ERODE
public static final int RGB_ERODE
- See Also:
- Constant Field Values
-
RGB_DILATE
public static final int RGB_DILATE
- See Also:
- Constant Field Values
-
RGB_THRESHOLD
public static final int RGB_THRESHOLD
- See Also:
- Constant Field Values
-
RGB_ROTATE
public static final int RGB_ROTATE
- See Also:
- Constant Field Values
-
RGB_SCALE
public static final int RGB_SCALE
- See Also:
- Constant Field Values
-
RGB_RESIZE
public static final int RGB_RESIZE
- See Also:
- Constant Field Values
-
RGB_TRANSLATE
public static final int RGB_TRANSLATE
- See Also:
- Constant Field Values
-
RGB_MIN
public static final int RGB_MIN
- See Also:
- Constant Field Values
-
RGB_MAX
public static final int RGB_MAX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ColorProcessor
public ColorProcessor(java.awt.Image img)
Creates a ColorProcessor from an AWT Image or BufferedImage.
-
ColorProcessor
public ColorProcessor(int width, int height)Creates a blank ColorProcessor of the specified dimensions.
-
ColorProcessor
public ColorProcessor(int width, int height, int[] pixels)Creates a ColorProcessor from a pixel array.
-
-
Method Detail
-
createImage
public java.awt.Image createImage()
Description copied from class:ImageProcessorReturns a copy of this image is the form of an AWT Image.- Specified by:
createImagein classImageProcessor
-
setColorModel
public void setColorModel(java.awt.image.ColorModel cm)
Description copied from class:ImageProcessorSets the color model. Must be an IndexColorModel (aka LUT) for all processors except the ColorProcessor.- Overrides:
setColorModelin classImageProcessor
-
createProcessor
public ImageProcessor createProcessor(int width, int height)
Returns a new, blank ColorProcessor with the specified width and height.- Specified by:
createProcessorin classImageProcessor
-
getColor
public java.awt.Color getColor(int x, int y)
-
setColor
public void setColor(java.awt.Color color)
Sets the foreground color.- Specified by:
setColorin classImageProcessor
-
setBackgroundColor
public void setBackgroundColor(java.awt.Color color)
Sets the background fill/draw color.- Overrides:
setBackgroundColorin classImageProcessor
-
setColor
public void setColor(int color)
Sets the fill/draw color, wherecoloris an RGB int.- Overrides:
setColorin classImageProcessor
-
setValue
public void setValue(double value)
Sets the default fill/draw value, wherevalueis interpreted as an RGB int.- Specified by:
setValuein classImageProcessor
-
getForegroundValue
public double getForegroundValue()
Returns the foreground fill/draw value.- Specified by:
getForegroundValuein classImageProcessor
-
setBackgroundValue
public void setBackgroundValue(double value)
Sets the background fill value, wherevalueis interpreted as an RGB int.- Specified by:
setBackgroundValuein classImageProcessor
-
getBackgroundValue
public double getBackgroundValue()
Returns the background fill value.- Specified by:
getBackgroundValuein classImageProcessor
-
getMin
public double getMin()
Returns the smallest displayed pixel value.- Specified by:
getMinin classImageProcessor
-
getMax
public double getMax()
Returns the largest displayed pixel value.- Specified by:
getMaxin classImageProcessor
-
setMinAndMax
public void setMinAndMax(double min, double max)Uses a table look-up to map the pixels in this image from min-max to 0-255.- Specified by:
setMinAndMaxin classImageProcessor- See Also:
IJ.setMinAndMax(ij.ImagePlus,double,double)
-
setMinAndMax
public void setMinAndMax(double min, double max, int channels)
-
snapshot
public void snapshot()
Description copied from class:ImageProcessorMakes a copy of this image's pixel data that can be later restored using reset() or reset(mask).- Specified by:
snapshotin classImageProcessor- See Also:
ImageProcessor.reset(),ImageProcessor.reset(ImageProcessor)
-
reset
public void reset()
Description copied from class:ImageProcessorRestores the pixel data from the snapshot (undo) buffer.- Specified by:
resetin classImageProcessor
-
reset
public void reset(ImageProcessor mask)
Description copied from class:ImageProcessorRestores pixels from the snapshot buffer that are within the rectangular roi but not part of the mask.- Specified by:
resetin classImageProcessor
-
caSnapshot
public void caSnapshot(boolean set)
Used by the ContrastAdjuster
-
caSnapshot
public boolean caSnapshot()
Used by the ContrastAdjuster
-
swapPixelArrays
public void swapPixelArrays()
Swaps the pixel and snapshot (undo) arrays.- Specified by:
swapPixelArraysin classImageProcessor
-
setSnapshotPixels
public void setSnapshotPixels(java.lang.Object pixels)
Description copied from class:ImageProcessorSets a new pixel array for the snapshot (undo) buffer.- Specified by:
setSnapshotPixelsin classImageProcessor
-
getSnapshotPixels
public java.lang.Object getSnapshotPixels()
Returns a reference to the snapshot pixel array. Used by the ContrastAdjuster.- Specified by:
getSnapshotPixelsin classImageProcessor
-
fill
public void fill(ImageProcessor mask)
Fills pixels that are within roi and part of the mask. Does nothing if the mask is not the same as the the ROI.- Specified by:
fillin classImageProcessor- See Also:
ImageProcessor.setColor(Color),ImageProcessor.setValue(double),ImageProcessor.getMask(),ImageProcessor.fill(Roi)
-
getPixelsCopy
public java.lang.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.- Specified by:
getPixelsCopyin classImageProcessor- See Also:
ImageProcessor.snapshot(),ImageProcessor.setSnapshotCopyMode(boolean)
-
getPixel
public int getPixel(int x, int y)Description copied from class:ImageProcessorReturns 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.- Specified by:
getPixelin classImageProcessor- See Also:
ImageProcessor.getValue(int, int)
-
get
public final int get(int x, int y)Description copied from class:ImageProcessorThis is a faster version of getPixel() that does not do bounds checking.- Specified by:
getin classImageProcessor
-
set
public final void set(int x, int y, int value)Description copied from class:ImageProcessorThis is a faster version of putPixel() that does not clip out of range values and does not do bounds checking.- Specified by:
setin classImageProcessor
-
get
public final int get(int index)
- Specified by:
getin classImageProcessor
-
set
public final void set(int index, int value)- Specified by:
setin classImageProcessor
-
getf
public final float getf(int x, int y)Description copied from class:ImageProcessorReturns 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.- Specified by:
getfin classImageProcessor
-
setf
public final void setf(int x, int y, float value)Description copied from class:ImageProcessorSets 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.- Specified by:
setfin classImageProcessor
-
getf
public final float getf(int index)
- Specified by:
getfin classImageProcessor
-
setf
public final void setf(int index, float value)- Specified by:
setfin classImageProcessor
-
getPixel
public int[] getPixel(int x, int y, int[] iArray)Returns the 3 samples for the pixel at (x,y) in an array of int. Returns zeros if the the coordinates are not in bounds. iArray is an optional preallocated array.- Overrides:
getPixelin classImageProcessor
-
putPixel
public final void putPixel(int x, int y, int[] iArray)Sets a pixel in the image using a 3 element (R, G and B) int array of samples.- Overrides:
putPixelin classImageProcessor
-
getInterpolatedPixel
public double getInterpolatedPixel(double x, double y)Calls getPixelValue(x,y).- Specified by:
getInterpolatedPixelin classImageProcessor
-
getPixelInterpolated
public final int getPixelInterpolated(double x, double y)Description copied from class:ImageProcessorUses 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.- Specified by:
getPixelInterpolatedin classImageProcessor
-
putPixel
public final void putPixel(int x, int y, int value)Stores the specified value at (x,y).- Specified by:
putPixelin classImageProcessor
-
putPixelValue
public void putPixelValue(int x, int y, double value)Stores the specified real grayscale value at (x,y). Does nothing if (x,y) is outside the image boundary. The value is clamped to be in the range 0-255.- Specified by:
putPixelValuein classImageProcessor
-
getPixelValue
public float getPixelValue(int x, int y)Converts the specified pixel to grayscale using the formula g=(r+g+b)/3 and returns it as a float. Call setWeightingFactors() to specify different conversion factors.- Specified by:
getPixelValuein classImageProcessor- See Also:
ImageProcessor.getPixel(int, int),ImageProcessor.getValue(int, int),ImageProcessor.getf(int, int)
-
drawPixel
public void drawPixel(int x, int y)Draws a pixel in the current foreground color.- Specified by:
drawPixelin classImageProcessor
-
getPixels
public java.lang.Object getPixels()
Returns a reference to the int array containing this image's pixel data.- Specified by:
getPixelsin classImageProcessor
-
setPixels
public void setPixels(java.lang.Object pixels)
Description copied from class:ImageProcessorSets 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.- Specified by:
setPixelsin classImageProcessor
-
getHSB
public void getHSB(byte[] H, byte[] S, byte[] B)Returns hue, saturation and brightness in 3 byte arrays.
-
getHSB
public void getHSB(float[] H, float[] S, float[] B)Returns hue, saturation and brightness in 3 float arrays.
-
getHSBStack
public ImageStack getHSBStack()
Returns an ImageStack with three 8-bit slices, representing hue, saturation and brightness
-
getHSB32Stack
public ImageStack getHSB32Stack()
Returns an ImageStack with three 32-bit slices, representing hue, saturation and brightness
-
getBrightness
public FloatProcessor getBrightness()
Returns brightness as a FloatProcessor.
-
getRGB
public void getRGB(byte[] R, byte[] G, byte[] B)Returns the red, green and blue planes as 3 byte arrays.
-
getChannel
public byte[] getChannel(int channel)
Returns the specified plane (1=red, 2=green, 3=blue, 4=alpha) as a byte array.
-
getChannel
public ByteProcessor getChannel(int channel, ByteProcessor bp)
Returns the specified plane (1=red, 2=green, 3=blue, 4=alpha) as a ByteProcessor.
-
setChannel
public void setChannel(int channel, ByteProcessor bp)Sets the pixels of one color channel from a ByteProcessor.- Parameters:
channel- Determines the color channel, 1=red, 2=green, 3=blue, 4=alphabp- The ByteProcessor where the image data are read from.
-
setRGB
public void setRGB(byte[] R, byte[] G, byte[] B)Sets the current pixels from 3 byte arrays (reg, green, blue).
-
setHSB
public void setHSB(byte[] H, byte[] S, byte[] B)Sets the current pixels from 3 byte arrays (hue, saturation and brightness).
-
setHSB
public void setHSB(float[] H, float[] S, float[] B)Sets the current pixels from 3 float arrays (hue, saturation and brightness).
-
setBrightness
public void setBrightness(FloatProcessor fp)
Updates the brightness using the pixels in the specified FloatProcessor).
-
copyBits
public 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.- Specified by:
copyBitsin classImageProcessor
-
applyTable
public void applyTable(int[] lut)
Description copied from class:ImageProcessorTransforms 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.- Specified by:
applyTablein classImageProcessor
-
applyTable
public void applyTable(int[] lut, int channels)
-
fill
public void fill()
Fills the current rectangular ROI.- Overrides:
fillin classImageProcessor- See Also:
ImageProcessor.setColor(Color),ImageProcessor.setValue(double),ImageProcessor.fill(Roi)
-
filterRGB
public void filterRGB(int type, double arg)Performs the specified filter on the red, green and blue planes of this image.
-
noise
public void noise(double range)
Description copied from class:ImageProcessorAdds pseudorandom, Gaussian ("normally") distributed values, with mean 0.0 and the specified standard deviation, to this image or ROI.- Specified by:
noisein classImageProcessor
-
medianFilter
public void medianFilter()
Description copied from class:ImageProcessorA 3x3 median filter. Requires 8-bit or RGB image.- Specified by:
medianFilterin classImageProcessor
-
findEdges
public void findEdges()
Description copied from class:ImageProcessorFinds edges in the image or ROI using a Sobel operator.- Overrides:
findEdgesin classImageProcessor
-
erode
public void erode()
Description copied from class:ImageProcessorErodes the image or ROI using a 3x3 maximum filter. Requires 8-bit or RGB image.- Specified by:
erodein classImageProcessor
-
dilate
public void dilate()
Description copied from class:ImageProcessorDilates the image or ROI using a 3x3 minimum filter. Requires 8-bit or RGB image.- Specified by:
dilatein classImageProcessor
-
autoThreshold
public void autoThreshold()
Description copied from class:ImageProcessorConverts 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.- Overrides:
autoThresholdin classImageProcessor
-
scale
public void scale(double xScale, double yScale)Scales the image or selection using the specified scale factors.- Specified by:
scalein classImageProcessor- See Also:
ImageProcessor.setInterpolate(boolean)
-
crop
public ImageProcessor crop()
Description copied from class:ImageProcessorReturns a new processor containing an image that corresponds to the current ROI.- Specified by:
cropin classImageProcessor
-
duplicate
public ImageProcessor duplicate()
Returns a duplicate of this image.- Specified by:
duplicatein classImageProcessor
-
getInterpolatedRGBPixel
public int getInterpolatedRGBPixel(double x, double y)Uses bilinear interpolation to find the pixel value at real coordinates (x,y).
-
resize
public ImageProcessor resize(int dstWidth, int dstHeight)
Creates a new ColorProcessor containing a scaled copy of this image or selection.- Specified by:
resizein classImageProcessor- See Also:
ImageProcessor.setInterpolate(boolean)
-
makeThumbnail
public ImageProcessor makeThumbnail(int width2, int height2, double smoothFactor)
Uses averaging to creates a new ColorProcessor containing a downsized copy of this image or selection.
-
rotate
public void rotate(double angle)
Rotates the image or ROI 'angle' degrees clockwise.- Specified by:
rotatein classImageProcessor- See Also:
ImageProcessor.setInterpolationMethod(int)
-
flipVertical
public void flipVertical()
Description copied from class:ImageProcessorFlips the image or ROI vertically.- Specified by:
flipVerticalin classImageProcessor
-
convolve3x3
public void convolve3x3(int[] kernel)
3x3 convolution contributed by Glynne Casteel.- Specified by:
convolve3x3in classImageProcessor
-
filter
public void filter(int type)
A 3x3 filter operation, where the argument (ImageProcessor.BLUR_MORE, FIND_EDGES, MEDIAN_FILTER, MIN or MAX) determines the filter type.- Specified by:
filterin classImageProcessor
-
getHistogram
public int[] getHistogram()
Description copied from class:ImageProcessorReturns 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).
- Specified by:
getHistogramin classImageProcessor
-
getHistogram
public int[] getHistogram(ImageProcessor mask)
-
weightedHistogram
public boolean weightedHistogram()
-
convolve
public void convolve(float[] kernel, int kernelWidth, int kernelHeight)Performs a convolution operation using the specified kernel.- Specified by:
convolvein classImageProcessor
-
setWeightingFactors
public static void setWeightingFactors(double rFactor, double gFactor, double bFactor)Sets the weighting factors used by getPixelValue(), getHistogram() and convertToByte() to do color conversions. The default values are 1/3, 1/3 and 1/3. Check "Weighted RGB Conversions" in Edit/Options/Conversions to use 0.299, 0.587 and 0.114.
-
getWeightingFactors
public static double[] getWeightingFactors()
Returns the three weighting factors used by getPixelValue(), getHistogram() and convertToByte() to do color conversions.
-
setRGBWeights
public void setRGBWeights(double rweight, double gweight, double bweight)This is a thread-safe (non-static) version of setWeightingFactors().
-
setRGBWeights
public void setRGBWeights(double[] weights)
This is a thread-safe (non-static) version of setWeightingFactors().
-
getRGBWeights
public double[] getRGBWeights()
Returns the values set by setRGBWeights(), or null if setRGBWeights() has not been called.
-
isInvertedLut
public boolean isInvertedLut()
Always returns false since RGB images do not use LUTs.- Overrides:
isInvertedLutin classImageProcessor
-
isGrayscale
public final boolean isGrayscale()
Returns 'true' if this is a grayscale image.- Overrides:
isGrayscalein classImageProcessor
-
getBestIndex
public int getBestIndex(java.awt.Color c)
Always returns 0 since RGB images do not use LUTs.- Overrides:
getBestIndexin classImageProcessor
-
invertLut
public void invertLut()
Does nothing since RGB images do not use LUTs.- Overrides:
invertLutin classImageProcessor
-
updateComposite
public void updateComposite(int[] rgbPixels, int channel)Description copied from class:ImageProcessorThis method is used by CompositeImage.updateImage() to create RGB images (for display) of a multi-channel composite images.- Overrides:
updateCompositein classImageProcessor
-
threshold
public void threshold(int level)
Not implemented.- Specified by:
thresholdin classImageProcessor
-
getNChannels
public int getNChannels()
Returns the number of color channels (3).- Overrides:
getNChannelsin classImageProcessor- Returns:
- 1 for grayscale images, 3 for RGB images
-
toFloat
public FloatProcessor toFloat(int channelNumber, FloatProcessor fp)
Returns a FloatProcessor with one color channel of the image. The roi and mask are also set for the FloatProcessor.- Specified by:
toFloatin classImageProcessor- Parameters:
channelNumber- Determines the color channel, 0=red, 1=green, 2=bluefp- Here a FloatProcessor can be supplied, or null. The FloatProcessor is overwritten by this method (re-using its pixels array improves performance).- Returns:
- A FloatProcessor with the converted image data of the color channel selected
-
setPixels
public void setPixels(int channelNumber, FloatProcessor fp)Sets the pixels of one color channel from a FloatProcessor.- Specified by:
setPixelsin classImageProcessor- Parameters:
channelNumber- Determines the color channel, 0=red, 1=green, 2=bluefp- The FloatProcessor where the image data are read from.
-
getBitDepth
public int getBitDepth()
Description copied from class:ImageProcessorReturns the bit depth, 8, 16, 24 (RGB) or 32. RGB images actually use 32 bits per pixel.- Overrides:
getBitDepthin classImageProcessor
-
-