public class ColorProcessor extends ImageProcessor
| Modifier and Type | Field and Description |
|---|---|
protected int[] |
pixels |
static int |
RGB_DILATE |
static int |
RGB_ERODE |
static int |
RGB_FIND_EDGES |
static int |
RGB_MEDIAN |
static int |
RGB_NOISE |
static int |
RGB_RESIZE |
static int |
RGB_ROTATE |
static int |
RGB_SCALE |
static int |
RGB_THRESHOLD |
static int |
RGB_TRANSLATE |
protected int[] |
snapshotPixels |
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, FIND_EDGES, fmImage, font, fontMetrics, gLUT1, gLUT2, height, histogramMax, histogramMin, histogramSize, image, img, interpolate, interpolationMethod, inversionTested, invertedLut, ISODATA, ISODATA2, justification, LEFT_JUSTIFY, lineWidth, lutAnimation, lutUpdateMode, MAX, maxThreshold, MEDIAN_FILTER, MIN, minMaxSet, minThreshold, NEAREST_NEIGHBOR, newPixels, NO_LUT_UPDATE, NO_THRESHOLD, NONE, OVER_UNDER_LUT, raster, RED_LUT, RIGHT_JUSTIFY, rLUT1, rLUT2, roiHeight, roiWidth, roiX, roiY, sampleModel, snapshotHeight, snapshotWidth, source, width, xMax, xMin, yMax, yMin| Constructor and Description |
|---|
ColorProcessor(java.awt.Image img)
Creates a ColorProcessor from an AWT Image or BufferedImage.
|
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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
applyTable(int[] lut)
Transforms the image or ROI using a lookup table.
|
void |
applyTable(int[] lut,
int channels) |
void |
autoThreshold()
Converts the image to binary using an automatically determined threshold.
|
void |
convolve(float[] kernel,
int kernelWidth,
int kernelHeight)
Performs a convolution operation using the specified kernel.
|
void |
convolve3x3(int[] kernel)
3x3 convolution contributed by Glynne Casteel.
|
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.
|
java.awt.Image |
createImage()
Returns a copy of this image is the form of an AWT Image.
|
ImageProcessor |
createProcessor(int width,
int height)
Returns a new, blank ColorProcessor with the specified width and height.
|
ImageProcessor |
crop()
Creates a new processor containing an image
that corresponds to the current ROI.
|
void |
dilate()
Dilates the image or ROI using a 3x3 minimum filter.
|
void |
drawPixel(int x,
int y)
Draws a pixel in the current foreground color.
|
ImageProcessor |
duplicate()
Returns a duplicate of this image.
|
void |
erode()
Erodes the image or ROI using a 3x3 maximum filter.
|
void |
fill()
Fills the current rectangular ROI.
|
void |
fill(ImageProcessor mask)
Fills pixels that are within roi and part of the mask.
|
void |
filter(int type)
3x3 unweighted smoothing.
|
void |
filterRGB(int type,
double arg)
Performs the specified filter on the red, green and blue planes of this image.
|
void |
findEdges()
Finds edges in the image or ROI using a Sobel operator.
|
void |
flipVertical()
Flips the image or ROI vertically.
|
int |
get(int index) |
int |
get(int x,
int y)
This is a faster version of getPixel() that does not do bounds checking.
|
double |
getBackgroundValue()
Returns the background fill value.
|
int |
getBestIndex(java.awt.Color c)
Always returns 0 since RGB images do not use LUTs.
|
int |
getBitDepth()
Returns the bit depth, 8, 16, 24 (RGB) or 32.
|
FloatProcessor |
getBrightness()
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.
|
ByteProcessor |
getChannel(int channel,
ByteProcessor bp)
Returns the specified plane (1=red, 2=green, 3=blue, 4=alpha) as a ByteProcessor.
|
java.awt.Color |
getColor(int x,
int y) |
float |
getf(int index) |
float |
getf(int x,
int y)
Returns the value of the pixel at (x,y) as a float.
|
int[] |
getHistogram()
Returns the histogram of the image or ROI.
|
int[] |
getHistogram(ImageProcessor mask) |
void |
getHSB(byte[] H,
byte[] S,
byte[] B)
Returns hue, saturation and brightness in 3 byte arrays.
|
ImageStack |
getHSBStack()
Returns an ImageStack with three 8-bit slices,
representing hue, saturation and brightness
|
double |
getInterpolatedPixel(double x,
double y)
Calls getPixelValue(x,y).
|
int |
getInterpolatedRGBPixel(double x,
double y)
Uses bilinear interpolation to find the pixel value at real coordinates (x,y).
|
double |
getMax()
Returns the largest displayed pixel value.
|
double |
getMin()
Returns the smallest displayed pixel value.
|
int |
getNChannels()
Returns the number of color channels of the image, i.e., 3.
|
int |
getPixel(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.
|
int |
getPixelInterpolated(double x,
double y)
Uses the current interpolation method to find the pixel value at real coordinates (x,y).
|
java.lang.Object |
getPixels()
Returns a reference to the int array containing
this image's pixel data.
|
java.lang.Object |
getPixelsCopy()
Returns a copy of the pixel data.
|
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.
|
void |
getRGB(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.Object |
getSnapshotPixels()
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.
|
void |
invertLut()
Does nothing since RGB images do not use LUTs.
|
boolean |
isGrayscale()
Returns 'true' if this is a grayscale image.
|
boolean |
isInvertedLut()
Always returns false since RGB images do not use LUTs.
|
ImageProcessor |
makeThumbnail(int width2,
int height2,
double smoothFactor)
Uses averaging to creates a new ColorProcessor containing
a downsized copy of this image or selection.
|
void |
medianFilter()
A 3x3 median filter.
|
void |
noise(double range)
Adds pseudorandom, Gaussian ("normally") distributed values, with
mean 0.0 and the specified standard deviation, to this image or ROI.
|
void |
putPixel(int x,
int y,
int value)
Stores the specified value at (x,y).
|
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.
|
void |
putPixelValue(int x,
int y,
double value)
Stores the specified real grayscale value at (x,y).
|
void |
reset()
Restores the pixel data from the snapshot (undo) buffer.
|
void |
reset(ImageProcessor mask)
Restores pixels from the snapshot buffer that are
within the rectangular roi but not part of the mask.
|
ImageProcessor |
resize(int dstWidth,
int dstHeight)
Creates a new ColorProcessor containing a scaled copy of this image or selection.
|
void |
rotate(double angle)
Rotates the image or ROI 'angle' degrees clockwise.
|
void |
scale(double xScale,
double yScale)
Scales the image or selection using the specified scale factors.
|
void |
set(int index,
int value) |
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.
|
void |
setBackgroundValue(double value)
Sets the background fill value, where
value is interpreted as an RGB int. |
void |
setBrightness(FloatProcessor fp)
Updates the brightness using the pixels in the specified FloatProcessor).
|
void |
setChannel(int channel,
ByteProcessor bp)
Sets the pixels of one color channel from a ByteProcessor.
|
void |
setColor(java.awt.Color color)
Sets the foreground color.
|
void |
setColor(int color)
Sets the fill/draw color, where
color is an RGB int. |
void |
setColorModel(java.awt.image.ColorModel cm)
Sets the color model.
|
void |
setf(int index,
float value) |
void |
setf(int x,
int y,
float value)
Sets the value of the pixel at (x,y) to 'value'.
|
void |
setHSB(byte[] H,
byte[] S,
byte[] B)
Sets the current pixels from 3 byte arrays (hue, saturation and brightness).
|
void |
setMinAndMax(double min,
double max)
Uses a table look-up to map the pixels in this image from min-max to 0-255.
|
void |
setMinAndMax(double min,
double max,
int channels) |
void |
setPixels(int channelNumber,
FloatProcessor fp)
Sets the pixels of one color channel from a FloatProcessor.
|
void |
setPixels(java.lang.Object pixels)
Sets a new pixel array for the image.
|
void |
setRGB(byte[] R,
byte[] G,
byte[] B)
Sets the current pixels from 3 byte arrays (reg, green, blue).
|
void |
setRGBWeights(double rweight,
double gweight,
double bweight)
This is a thread-safe (non-static) version of setWeightingFactors().
|
void |
setSnapshotPixels(java.lang.Object pixels)
Sets a new pixel array for the snapshot (undo) buffer.
|
void |
setValue(double value)
Sets the default fill/draw value, where
value is interpreted as an RGB int. |
static void |
setWeightingFactors(double rFactor,
double gFactor,
double bFactor)
Sets the weighting factors used by getPixelValue(), getHistogram()
and convertToByte() to do color conversions.
|
void |
snapshot()
Makes a copy of this image's pixel data that can be
later restored using reset() or reset(mask).
|
void |
swapPixelArrays()
Swaps the pixel and snapshot (undo) arrays.
|
void |
threshold(int level)
Not implemented.
|
FloatProcessor |
toFloat(int channelNumber,
FloatProcessor fp)
Returns a FloatProcessor with one color channel of the image.
|
void |
updateComposite(int[] rgbPixels,
int channel)
CompositeImage calls this method to generate an updated color image.
|
abs, add, add, and, applyMacro, bin, blurGaussian, clone, convertToByte, convertToByteProcessor, convertToByteProcessor, convertToColorProcessor, convertToFloat, convertToFloatProcessor, convertToRGB, convertToShort, convertToShortProcessor, convertToShortProcessor, cubic, draw, drawDot, drawDot2, drawLine, drawOval, drawOverlay, drawPolygon, drawRect, drawRoi, drawString, drawString, drawString, exp, fill, fillOutside, fillOval, fillPolygon, flipHorizontal, gamma, getAutoThreshold, getAutoThreshold, getBicubicInterpolatedPixel, getBufferedImage, getCalibrationTable, getColorModel, getColumn, getCurrentColorModel, getDefaultColorModel, getFloatArray, getFont, getFontMetrics, getHeight, 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, getStringWidth, getWidth, hideProgress, insert, invert, isBinary, isColorLut, isDefaultLut, isKillable, isPseudoColorLut, lineTo, ln, log, makeDefaultColorModel, maskSizeError, max, maxValue, min, minValue, moveTo, multiply, or, putColumn, putRow, putRow, resetBinaryThreshold, resetMinAndMax, resetRoi, resetThreshold, resize, resize, resizeLinearly, rotateLeft, rotateRight, set, setAntialiasedText, setAutoThreshold, setAutoThreshold, setAutoThreshold, setAutoThreshold, setAutoThreshold, setBinaryThreshold, setCalibrationTable, setClipRect, setColor, setFloatArray, setFont, setHistogramRange, setHistogramSize, setIntArray, setInterpolate, setInterpolationMethod, setJustification, setLineWidth, setLut, setLutAnimation, setMask, setOverColor, setOverlay, setProgressBar, setRoi, setRoi, setRoi, setRoi, setSliceNumber, setSnapshotCopyMode, setThreshold, setUnderColor, setUseBicubic, sharpen, showProgress, smooth, sqr, sqrt, subtract, toString, translate, translate, xorprotected int[] pixels
protected int[] snapshotPixels
public static final int RGB_NOISE
public static final int RGB_MEDIAN
public static final int RGB_FIND_EDGES
public static final int RGB_ERODE
public static final int RGB_DILATE
public static final int RGB_THRESHOLD
public static final int RGB_ROTATE
public static final int RGB_SCALE
public static final int RGB_RESIZE
public static final int RGB_TRANSLATE
public ColorProcessor(java.awt.Image img)
public ColorProcessor(int width,
int height)
public ColorProcessor(int width,
int height,
int[] pixels)
public java.awt.Image createImage()
ImageProcessorcreateImage in class ImageProcessorpublic void setColorModel(java.awt.image.ColorModel cm)
ImageProcessorsetColorModel in class ImageProcessorpublic ImageProcessor createProcessor(int width, int height)
createProcessor in class ImageProcessorpublic java.awt.Color getColor(int x,
int y)
public void setColor(java.awt.Color color)
setColor in class ImageProcessorpublic void setColor(int color)
color is an RGB int.setColor in class ImageProcessorpublic void setValue(double value)
value is interpreted as an RGB int.setValue in class ImageProcessorpublic void setBackgroundValue(double value)
value is interpreted as an RGB int.setBackgroundValue in class ImageProcessorpublic double getBackgroundValue()
getBackgroundValue in class ImageProcessorpublic double getMin()
getMin in class ImageProcessorpublic double getMax()
getMax in class ImageProcessorpublic void setMinAndMax(double min,
double max)
setMinAndMax in class ImageProcessorpublic void setMinAndMax(double min,
double max,
int channels)
public void snapshot()
ImageProcessorsnapshot in class ImageProcessorImageProcessor.reset(),
ImageProcessor.reset(ImageProcessor)public void reset()
ImageProcessorreset in class ImageProcessorpublic void reset(ImageProcessor mask)
ImageProcessorreset in class ImageProcessorpublic void swapPixelArrays()
swapPixelArrays in class ImageProcessorpublic void setSnapshotPixels(java.lang.Object pixels)
ImageProcessorsetSnapshotPixels in class ImageProcessorpublic java.lang.Object getSnapshotPixels()
getSnapshotPixels in class ImageProcessorpublic void fill(ImageProcessor mask)
fill in class ImageProcessorImageProcessor.setColor(Color),
ImageProcessor.setValue(double),
ImageProcessor.getMask(),
ImageProcessor.fill(Roi)public java.lang.Object getPixelsCopy()
getPixelsCopy in class ImageProcessorImageProcessor.snapshot(),
ImageProcessor.setSnapshotCopyMode(boolean)public int getPixel(int x,
int y)
ImageProcessorgetPixel in class ImageProcessorpublic final int get(int x,
int y)
ImageProcessorget in class ImageProcessorpublic final void set(int x,
int y,
int value)
ImageProcessorset in class ImageProcessorpublic final int get(int index)
get in class ImageProcessorpublic final void set(int index,
int value)
set in class ImageProcessorpublic final float getf(int x,
int y)
ImageProcessorgetf in class ImageProcessorpublic final void setf(int x,
int y,
float value)
ImageProcessorsetf in class ImageProcessorpublic final float getf(int index)
getf in class ImageProcessorpublic final void setf(int index,
float value)
setf in class ImageProcessorpublic int[] getPixel(int x,
int y,
int[] iArray)
getPixel in class ImageProcessorpublic final void putPixel(int x,
int y,
int[] iArray)
putPixel in class ImageProcessorpublic double getInterpolatedPixel(double x,
double y)
getInterpolatedPixel in class ImageProcessorpublic final int getPixelInterpolated(double x,
double y)
ImageProcessorgetPixelInterpolated in class ImageProcessorpublic final void putPixel(int x,
int y,
int value)
putPixel in class ImageProcessorpublic void putPixelValue(int x,
int y,
double value)
putPixelValue in class ImageProcessorpublic float getPixelValue(int x,
int y)
getPixelValue in class ImageProcessorpublic void drawPixel(int x,
int y)
drawPixel in class ImageProcessorpublic java.lang.Object getPixels()
getPixels in class ImageProcessorpublic void setPixels(java.lang.Object pixels)
ImageProcessorsetPixels in class ImageProcessorpublic void getHSB(byte[] H,
byte[] S,
byte[] B)
public ImageStack getHSBStack()
public FloatProcessor getBrightness()
public void getRGB(byte[] R,
byte[] G,
byte[] B)
public byte[] getChannel(int channel)
public ByteProcessor getChannel(int channel, ByteProcessor bp)
public void setChannel(int channel,
ByteProcessor bp)
channel - Determines the color channel, 1=red, 2=green, 3=blue, 4=alphabp - The ByteProcessor where the image data are read from.public void setRGB(byte[] R,
byte[] G,
byte[] B)
public void setHSB(byte[] H,
byte[] S,
byte[] B)
public void setBrightness(FloatProcessor fp)
public void copyBits(ImageProcessor ip, int xloc, int yloc, int mode)
copyBits in class ImageProcessorpublic void applyTable(int[] lut)
ImageProcessorapplyTable in class ImageProcessorpublic void applyTable(int[] lut,
int channels)
public void fill()
fill in class ImageProcessorImageProcessor.setColor(Color),
ImageProcessor.setValue(double),
ImageProcessor.fill(Roi)public void filterRGB(int type,
double arg)
public void noise(double range)
ImageProcessornoise in class ImageProcessorpublic void medianFilter()
ImageProcessormedianFilter in class ImageProcessorpublic void findEdges()
ImageProcessorfindEdges in class ImageProcessorpublic void erode()
ImageProcessorerode in class ImageProcessorpublic void dilate()
ImageProcessordilate in class ImageProcessorpublic void autoThreshold()
ImageProcessorautoThreshold in class ImageProcessorpublic void scale(double xScale,
double yScale)
scale in class ImageProcessorImageProcessor.setInterpolate(boolean)public ImageProcessor crop()
ImageProcessorcrop in class ImageProcessorpublic ImageProcessor duplicate()
duplicate in class ImageProcessorpublic int getInterpolatedRGBPixel(double x,
double y)
public ImageProcessor resize(int dstWidth, int dstHeight)
resize in class ImageProcessorImageProcessor.setInterpolate(boolean)public ImageProcessor makeThumbnail(int width2, int height2, double smoothFactor)
public void rotate(double angle)
rotate in class ImageProcessorImageProcessor.setInterpolationMethod(int)public void flipVertical()
ImageProcessorflipVertical in class ImageProcessorpublic void convolve3x3(int[] kernel)
convolve3x3 in class ImageProcessorpublic void filter(int type)
filter in class ImageProcessorpublic int[] getHistogram()
ImageProcessorFor 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 in class ImageProcessorpublic int[] getHistogram(ImageProcessor mask)
public void convolve(float[] kernel,
int kernelWidth,
int kernelHeight)
convolve in class ImageProcessorpublic static void setWeightingFactors(double rFactor,
double gFactor,
double bFactor)
public static double[] getWeightingFactors()
public void setRGBWeights(double rweight,
double gweight,
double bweight)
public double[] getRGBWeights()
public boolean isInvertedLut()
isInvertedLut in class ImageProcessorpublic final boolean isGrayscale()
isGrayscale in class ImageProcessorpublic int getBestIndex(java.awt.Color c)
getBestIndex in class ImageProcessorpublic void invertLut()
invertLut in class ImageProcessorpublic void updateComposite(int[] rgbPixels,
int channel)
ImageProcessorupdateComposite in class ImageProcessorpublic void threshold(int level)
threshold in class ImageProcessorpublic int getNChannels()
getNChannels in class ImageProcessorpublic FloatProcessor toFloat(int channelNumber, FloatProcessor fp)
toFloat in class ImageProcessorchannelNumber - 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).public void setPixels(int channelNumber,
FloatProcessor fp)
setPixels in class ImageProcessorchannelNumber - Determines the color channel, 0=red, 1=green, 2=bluefp - The FloatProcessor where the image data are read from.public int getBitDepth()
ImageProcessorgetBitDepth in class ImageProcessor