Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
ColorProcessor Class Reference
Inheritance diagram for ColorProcessor:
ImageProcessor

Public Member Functions

 ColorProcessor (Image img)
 
 ColorProcessor (int width, int height)
 
 ColorProcessor (int width, int height, int[] pixels)
 
Image createImage ()
 
ImageProcessor createProcessor (int width, int height)
 
Color getColor (int x, int y)
 
void setColor (Color color)
 
void setValue (double value)
 
double getMin ()
 
double getMax ()
 
void setMinAndMax (double min, double max)
 
void setMinAndMax (double min, double max, int channels)
 
void snapshot ()
 
void reset ()
 
void reset (ImageProcessor mask)
 
void fill (ImageProcessor mask)
 
Object getPixelsCopy ()
 
Object getSnapshotPixels ()
 
int getPixel (int x, int y)
 
int[] getPixel (int x, int y, int[] iArray)
 
void putPixel (int x, int y, int[] iArray)
 
double getInterpolatedPixel (double x, double y)
 
void putPixel (int x, int y, int value)
 
void putPixelValue (int x, int y, double value)
 
float getPixelValue (int x, int y)
 
void drawPixel (int x, int y)
 
Object getPixels ()
 
void setPixels (Object pixels)
 
void getHSB (byte[] H, byte[] S, byte[] B)
 
FloatProcessor getBrightness ()
 
void getRGB (byte[] R, byte[] G, byte[] B)
 
void setRGB (byte[] R, byte[] G, byte[] B)
 
void setHSB (byte[] H, byte[] S, byte[] B)
 
void setBrightness (FloatProcessor fp)
 
void copyBits (ImageProcessor ip, int xloc, int yloc, int mode)
 
void applyTable (int[] lut)
 
void applyTable (int[] lut, int channels)
 
void fill ()
 
void filterRGB (int type, double arg)
 
void noise (double range)
 
void medianFilter ()
 
void findEdges ()
 
void erode ()
 
void dilate ()
 
void autoThreshold ()
 
void scale (double xScale, double yScale)
 
ImageProcessor crop ()
 
int getInterpolatedRGBPixel (double x, double y)
 
ImageProcessor resize (int dstWidth, int dstHeight)
 
void rotate (double angle)
 
void flipVertical ()
 
void convolve3x3 (int[] kernel)
 
void filter (int type)
 
int[] getHistogram ()
 
int[] getHistogram (ImageProcessor mask)
 
void convolve (float[] kernel, int kernelWidth, int kernelHeight)
 
boolean isInvertedLut ()
 
int getBestIndex (Color c)
 
void invertLut ()
 
void threshold (int level)
 
- Public Member Functions inherited from ImageProcessor
int getWidth ()
 
int getHeight ()
 
ColorModel getColorModel ()
 
void setColorModel (ColorModel cm)
 
void invertLut ()
 
int getBestIndex (Color c)
 
boolean isInvertedLut ()
 
boolean isColorLut ()
 
boolean isPseudoColorLut ()
 
void setColor (int value)
 
void resetMinAndMax ()
 
void setThreshold (double minThreshold, double maxThreshold, int lutUpdate)
 
void resetThreshold ()
 
double getMinThreshold ()
 
double getMaxThreshold ()
 
void setRoi (Rectangle roi)
 
void setRoi (int x, int y, int rwidth, int rheight)
 
void setRoi (ij.gui.Roi roi)
 
void setRoi (Polygon roi)
 
void resetRoi ()
 
Rectangle getRoi ()
 
void setMask (ImageProcessor mask)
 
ImageProcessor getMask ()
 
byte[] getMaskArray ()
 
void setProgressBar (ProgressBar pb)
 
void setInterpolate (boolean interpolate)
 
boolean getInterpolate ()
 
boolean isKillable ()
 
double[] getLine (double x1, double y1, double x2, double y2)
 
void getRow (int x, int y, int[] data, int length)
 
void getColumn (int x, int y, int[] data, int length)
 
void putRow (int x, int y, int[] data, int length)
 
void putColumn (int x, int y, int[] data, int length)
 
void moveTo (int x, int y)
 
void setLineWidth (int width)
 
void lineTo (int x2, int y2)
 
void drawLine (int x1, int y1, int x2, int y2)
 
void drawRect (int x, int y, int width, int height)
 
void drawPolygon (Polygon p)
 
void fillPolygon (Polygon p)
 
void drawDot2 (int x, int y)
 
void drawDot (int xcenter, int ycenter)
 
void drawString (String s)
 
void drawString (String s, int x, int y)
 
void setJustification (int justification)
 
void setFont (Font font)
 
void setAntialiasedText (boolean antialiasedText)
 
int getStringWidth (String s)
 
FontMetrics getFontMetrics ()
 
void smooth ()
 
void sharpen ()
 
void findEdges ()
 
void flipHorizontal ()
 
ImageProcessor rotateRight ()
 
ImageProcessor rotateLeft ()
 
void insert (ImageProcessor ip, int xloc, int yloc)
 
String toString ()
 
void fill ()
 
void setCalibrationTable (float[] cTable)
 
void setHistogramSize (int size)
 
int getHistogramSize ()
 
void setHistogramRange (double histMin, double histMax)
 
double getHistogramMin ()
 
double getHistogramMax ()
 
int[] getPixel (int x, int y, int[] iArray)
 
void putPixel (int x, int y, int[] iArray)
 
double getInterpolatedValue (double x, double y)
 
void invert ()
 
void add (int value)
 
void add (double value)
 
void multiply (double value)
 
void and (int value)
 
void or (int value)
 
void xor (int value)
 
void gamma (double value)
 
void log ()
 
void sqr ()
 
void sqrt ()
 
void min (double value)
 
void max (double value)
 
ImageProcessor duplicate ()
 
void setLutAnimation (boolean lutAnimation)
 
ImageProcessor convertToByte (boolean doScaling)
 
ImageProcessor convertToShort (boolean doScaling)
 
ImageProcessor convertToFloat ()
 
ImageProcessor convertToRGB ()
 
void autoThreshold ()
 
int getAutoThreshold ()
 
int getAutoThreshold (int[] histogram)
 
void setClipRect (Rectangle clipRect)
 

Static Public Member Functions

static void setWeightingFactors (double rFactor, double gFactor, double bFactor)
 
static double[] getWeightingFactors ()
 

Data Fields

final int RGB_NOISE =0
 

Protected Attributes

int[] pixels
 
int[] snapshotPixels = null
 
- Protected Attributes inherited from ImageProcessor
int lineWidth = 1
 
int cx
 
Font font
 
FontMetrics fontMetrics
 
boolean antialiasedText
 
boolean boldFont
 
int width
 
int height
 
int roiX
 
int xMin
 
ColorModel baseCM
 
ColorModel cm
 
byte[] rLUT1
 
byte[] rLUT2
 
boolean interpolate
 
double minThreshold =NO_THRESHOLD
 
int histogramSize = 256
 
double histogramMin
 
float[] cTable
 
boolean lutAnimation
 
MemoryImageSource source
 
Image img
 
boolean newPixels
 
Color drawingColor = Color.black
 
int clipXMin
 
int justification = LEFT_JUSTIFY
 
boolean inversionTested = false
 
boolean invertedLut
 

Additional Inherited Members

- Static Public Attributes inherited from ImageProcessor
static final int BLACK = 0xFF000000
 
static final double NO_THRESHOLD = -808080.0
 
static final int LEFT_JUSTIFY = 0
 
static final int CENTER_JUSTIFY = 1
 
static final int RIGHT_JUSTIFY = 2
 
static final int RED_LUT =0
 
- Protected Member Functions inherited from ImageProcessor
void showProgress (double percentDone)
 
void hideProgress ()
 
void makeDefaultColorModel ()
 
String maskSizeError (ImageProcessor mask)
 

Detailed Description

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 (http://www.sn.no/~espeset).

Definition at line 12 of file ColorProcessor.java.

Constructor & Destructor Documentation

ColorProcessor ( Image  img)
inline

Creates a ColorProcessor from an AWT Image.

Definition at line 24 of file ColorProcessor.java.

ColorProcessor ( int  width,
int  height 
)
inline

Creates a blank ColorProcessor of the specified dimensions.

Definition at line 38 of file ColorProcessor.java.

ColorProcessor ( int  width,
int  height,
int[]  pixels 
)
inline

Creates a ColorProcessor from a pixel array.

Definition at line 43 of file ColorProcessor.java.

Member Function Documentation

void applyTable ( int[]  lut)
inlinevirtual

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.

Implements ImageProcessor.

Definition at line 412 of file ColorProcessor.java.

void convolve ( float[]  kernel,
int  kernelWidth,
int  kernelHeight 
)
inlinevirtual

Performs a convolution operation using the specified kernel.

Implements ImageProcessor.

Definition at line 978 of file ColorProcessor.java.

void convolve3x3 ( int[]  kernel)
inlinevirtual

3x3 convolution contributed by Glynne Casteel.

Implements ImageProcessor.

Definition at line 798 of file ColorProcessor.java.

void copyBits ( ImageProcessor  ip,
int  xloc,
int  yloc,
int  mode 
)
inlinevirtual

Copies the image contained in 'ip' to (xloc, yloc) using one of the transfer modes defined in the Blitter interface.

Implements ImageProcessor.

Definition at line 404 of file ColorProcessor.java.

Image createImage ( )
inlinevirtual

Returns a copy of this image is the form of an AWT Image.

Implements ImageProcessor.

Definition at line 59 of file ColorProcessor.java.

ImageProcessor createProcessor ( int  width,
int  height 
)
inlinevirtual

Returns a new, blank ShortProcessor with the specified width and height.

Implements ImageProcessor.

Definition at line 75 of file ColorProcessor.java.

ImageProcessor crop ( )
inlinevirtual

Creates a new processor containing an image that corresponds to the current ROI.

Implements ImageProcessor.

Definition at line 622 of file ColorProcessor.java.

void dilate ( )
inlinevirtual

Dilates the image or ROI using a 3x3 minimum filter. Requires 8-bit or RGB image.

Implements ImageProcessor.

Definition at line 556 of file ColorProcessor.java.

void drawPixel ( int  x,
int  y 
)
inlinevirtual

Draws a pixel in the current foreground color.

Implements ImageProcessor.

Definition at line 293 of file ColorProcessor.java.

void erode ( )
inlinevirtual

Erodes the image or ROI using a 3x3 maximum filter. Requires 8-bit or RGB image.

Implements ImageProcessor.

Definition at line 552 of file ColorProcessor.java.

void fill ( ImageProcessor  mask)
inlinevirtual

Fills pixels that are within roi and part of the mask. Throws an IllegalArgumentException if the mask is null or the size of the mask is not the same as the size of the ROI.

Implements ImageProcessor.

Definition at line 183 of file ColorProcessor.java.

void fill ( )
inline

Fills the current rectangular ROI.

Definition at line 467 of file ColorProcessor.java.

void filter ( int  type)
inlinevirtual

3x3 unweighted smoothing.

Implements ImageProcessor.

Definition at line 886 of file ColorProcessor.java.

void filterRGB ( int  type,
double  arg 
)
inline

Performs the specified 3x3 filter on the reg, green and blue planes.

Definition at line 483 of file ColorProcessor.java.

void flipVertical ( )
inlinevirtual

Flips the image or ROI vertically.

Implements ImageProcessor.

Definition at line 782 of file ColorProcessor.java.

int getBestIndex ( Color  c)
inline

Always returns 0 since RGB images do not use LUTs.

Definition at line 1029 of file ColorProcessor.java.

FloatProcessor getBrightness ( )
inline

Returns brightness as a FloatProcessor.

Definition at line 331 of file ColorProcessor.java.

int [] getHistogram ( )
inlinevirtual

Returns the histogram of the image or ROI. Returns a luminosity histogram for RGB images and null for float images.

Implements ImageProcessor.

Definition at line 927 of file ColorProcessor.java.

void getHSB ( byte[]  H,
byte[]  S,
byte[]  B 
)
inline

Returns hue, saturation and brightness in 3 byte arrays.

Definition at line 314 of file ColorProcessor.java.

double getInterpolatedPixel ( double  x,
double  y 
)
inlinevirtual

Calls getPixelValue(x,y).

Implements ImageProcessor.

Definition at line 245 of file ColorProcessor.java.

int getInterpolatedRGBPixel ( double  x,
double  y 
)
inline

Uses bilinear interpolation to find the pixel value at real coordinates (x,y).

Definition at line 635 of file ColorProcessor.java.

double getMax ( )
inlinevirtual

Returns the largest displayed pixel value.

Implements ImageProcessor.

Definition at line 110 of file ColorProcessor.java.

double getMin ( )
inlinevirtual

Returns the smallest displayed pixel value.

Implements ImageProcessor.

Definition at line 104 of file ColorProcessor.java.

int getPixel ( int  x,
int  y 
)
inlinevirtual

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.

Implements ImageProcessor.

Definition at line 217 of file ColorProcessor.java.

int [] getPixel ( int  x,
int  y,
int[]  iArray 
)
inline

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.

Definition at line 228 of file ColorProcessor.java.

Object getPixels ( )
inlinevirtual

Returns a reference to the int array containing this image's pixel data.

Implements ImageProcessor.

Definition at line 301 of file ColorProcessor.java.

Object getPixelsCopy ( )
inlinevirtual

Returns a reference to this image's snapshot (undo) array. If the snapshot array is null, returns a copy of the pixel data. The array type varies depending on the image type.

Implements ImageProcessor.

Definition at line 201 of file ColorProcessor.java.

float getPixelValue ( int  x,
int  y 
)
inlinevirtual

Converts the specified pixel to grayscale using the formula g=r/3+g/3+b/3 and returns it as a float. Call setWeightingFactors() for weighted conversions.

Implements ImageProcessor.

Definition at line 279 of file ColorProcessor.java.

void getRGB ( byte[]  R,
byte[]  G,
byte[]  B 
)
inline

Returns the red, green and blue planes as 3 byte arrays.

Definition at line 348 of file ColorProcessor.java.

Object getSnapshotPixels ( )
inline

Returns a reference to the snapshot pixel array. Used by the ContrastAdjuster.

Definition at line 213 of file ColorProcessor.java.

static double [] getWeightingFactors ( )
inlinestatic

Returns the three weighting factors used by getPixelValue(), getHistogram() and convertToByte() to do color conversions.

Definition at line 1015 of file ColorProcessor.java.

void invertLut ( )
inline

Does nothing since RGB images do not use LUTs.

Definition at line 1034 of file ColorProcessor.java.

boolean isInvertedLut ( )
inline

Always returns false since RGB images do not use LUTs.

Definition at line 1024 of file ColorProcessor.java.

void medianFilter ( )
inlinevirtual

A 3x3 median filter. Requires 8-bit or RGB image.

Implements ImageProcessor.

Definition at line 544 of file ColorProcessor.java.

void noise ( double  range)
inlinevirtual

Adds random noise to the image or ROI.

Parameters
rangethe range of random numbers

Implements ImageProcessor.

Definition at line 540 of file ColorProcessor.java.

void putPixel ( int  x,
int  y,
int[]  iArray 
)
inline

Sets a pixel in the image using a 3 element (R, G and B) int array of samples.

Definition at line 239 of file ColorProcessor.java.

void putPixel ( int  x,
int  y,
int  value 
)
inlinevirtual

Stores the specified value at (x,y).

Implements ImageProcessor.

Definition at line 256 of file ColorProcessor.java.

void putPixelValue ( int  x,
int  y,
double  value 
)
inlinevirtual

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.

Implements ImageProcessor.

Definition at line 264 of file ColorProcessor.java.

void reset ( )
inlinevirtual

Restores the pixel data from the snapshot (undo) buffer.

Implements ImageProcessor.

Definition at line 154 of file ColorProcessor.java.

void reset ( ImageProcessor  mask)
inlinevirtual

Restore pixels that are within roi but not part of the mask.

Implements ImageProcessor.

Definition at line 162 of file ColorProcessor.java.

ImageProcessor resize ( int  dstWidth,
int  dstHeight 
)
inlinevirtual

Creates a new ColorProcessor containing a scaled copy of this image or selection.

See Also
ImageProcessor::setInterpolate

Implements ImageProcessor.

Definition at line 689 of file ColorProcessor.java.

void rotate ( double  angle)
inlinevirtual

Rotates the image or ROI 'angle' degrees clockwise.

See Also
ImageProcessor::setInterpolate

Implements ImageProcessor.

Definition at line 733 of file ColorProcessor.java.

void scale ( double  xScale,
double  yScale 
)
inlinevirtual

Scales the image or selection using the specified scale factors.

See Also
ImageProcessor::setInterpolate

Implements ImageProcessor.

Definition at line 568 of file ColorProcessor.java.

void setBrightness ( FloatProcessor  fp)
inline

Updates the brightness using the pixels in the specified FloatProcessor).

Definition at line 382 of file ColorProcessor.java.

void setColor ( Color  color)
inlinevirtual

Sets the foreground color.

Implements ImageProcessor.

Definition at line 92 of file ColorProcessor.java.

void setHSB ( byte[]  H,
byte[]  S,
byte[]  B 
)
inline

Sets the current pixels from 3 byte arrays (hue, saturation and brightness).

Definition at line 371 of file ColorProcessor.java.

void setMinAndMax ( double  min,
double  max 
)
inlinevirtual

Uses a table look-up to map the pixels in this image from min-max to 0-255.

Implements ImageProcessor.

Definition at line 116 of file ColorProcessor.java.

void setPixels ( Object  pixels)
inlinevirtual

Sets a new pixel array for the image and resets the snapshot buffer. The length of the array must be equal to width*height.

Implements ImageProcessor.

Definition at line 306 of file ColorProcessor.java.

void setRGB ( byte[]  R,
byte[]  G,
byte[]  B 
)
inline

Sets the current pixels from 3 byte arrays (reg, green, blue).

Definition at line 363 of file ColorProcessor.java.

void setValue ( double  value)
inlinevirtual

Sets the default fill/draw value, where value is interpreted as an RGB int.

Implements ImageProcessor.

Definition at line 99 of file ColorProcessor.java.

static void setWeightingFactors ( double  rFactor,
double  gFactor,
double  bFactor 
)
inlinestatic

Sets the weighting factors used by getPixelValue(), getHistogram() and convertToByte() to do color conversions. The default values are 0.299, 0.587 and 0.114. Check "Unweighted Color Conversions" in Edit/Options/Conversions to use 1/3, 1/3 and 1/3.

Definition at line 1007 of file ColorProcessor.java.

void snapshot ( )
inlinevirtual

Makes a copy of this image's pixel data.

Implements ImageProcessor.

Definition at line 144 of file ColorProcessor.java.

void threshold ( int  level)
inlinevirtual

Not implemented.

Implements ImageProcessor.

Definition at line 1038 of file ColorProcessor.java.


The documentation for this class was generated from the following file: