Imp
[using it]
Interface Manipulation Package v4.0 (2008-06-25) a-projector ©copyright Author


imp.ima
Class RgbImage

java.lang.Object
  extended by java.awt.Image
      extended by java.awt.image.BufferedImage
          extended by imp.ima.RgbImage
All Implemented Interfaces:
RenderedImage, WritableRenderedImage, Transparency

public class RgbImage
extends BufferedImage

Encapsulates a RGB color image with standard algorithms.


Field Summary
 
Fields inherited from class java.awt.image.BufferedImage
TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR, TYPE_4BYTE_ABGR_PRE, TYPE_BYTE_BINARY, TYPE_BYTE_GRAY, TYPE_BYTE_INDEXED, TYPE_CUSTOM, TYPE_INT_ARGB, TYPE_INT_ARGB_PRE, TYPE_INT_BGR, TYPE_INT_RGB, TYPE_USHORT_555_RGB, TYPE_USHORT_565_RGB, TYPE_USHORT_GRAY
 
Fields inherited from class java.awt.Image
SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty
 
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
 
Constructor Summary
RgbImage(BufferedImage image)
          Creates an image from the RgbImage.
RgbImage(int width, int height, int[] pixels)
          Creates an image of the given sizes from the given buffer
RgbImage(String location)
          Creates an image reading the given URL.
 
Method Summary
 RgbImage getChannel(String channel)
          Returns maps of some image channels.
 RgbImage getCrop(int u, int v, int width, int height)
          Returns a sub-image of upper-left corner (u, v) and size (width, height).
 RgbImage getEdgeMap(int window, int threshold, String channel)
          Returns maps related to the image edges.
 RgbImage getFiltered(RgbFilter filter)
          Returns a filtered image of this.
 RgbImage getGamma(double gamma)
          Returns a normalized intensity image.
 int getHeight()
          Gets the image height
 RgbImage getNoisy(double magnitude)
          Returns an image with an additional Gaussian noise.
 int[] getPixels()
          Gets the image pixels The [width*height] image buffer contains row by row pixels of the form 0xRRGGBB where RR, GG and BB are red, green and blue byte values.
 RgbImage getRectification(double[] H)
          Returns a geometrically rectification of the image.
 int[] getRegions(int window, int threshold)
          Returns a region's map of the image.
 RgbImage getScaled(int size)
          Returns an image of lower/higher size (multi-scaling).
 RgbImage getSmooth(int window)
          Returns a smoothed image.
 int getWidth()
          Gets the image width
 void save(String location)
          Saves the image in an URL.
 RgbImage subtract(double lambda, double mu, RgbImage val)
          Returns an image whose values are (lambda this - mu val) for each pixel.
 String toString()
          Returns a string view of the image with size and basic parameters as a string.
 
Methods inherited from class java.awt.image.BufferedImage
addTileObserver, coerceData, copyData, createGraphics, getAlphaRaster, getColorModel, getData, getData, getGraphics, getHeight, getMinTileX, getMinTileY, getMinX, getMinY, getNumXTiles, getNumYTiles, getProperty, getProperty, getPropertyNames, getRaster, getRGB, getRGB, getSampleModel, getSource, getSources, getSubimage, getTile, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getTransparency, getType, getWidth, getWritableTile, getWritableTileIndices, hasTileWriters, isAlphaPremultiplied, isTileWritable, releaseWritableTile, removeTileObserver, setData, setRGB, setRGB
 
Methods inherited from class java.awt.Image
flush, getAccelerationPriority, getCapabilities, getScaledInstance, setAccelerationPriority
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RgbImage

public RgbImage(BufferedImage image)
Creates an image from the RgbImage.


RgbImage

public RgbImage(int width,
                int height,
                int[] pixels)
Creates an image of the given sizes from the given buffer

Parameters:
width - Image width.
height - [optional, default is image width] Image height.
pixels - [optional, default is empty buffer] Optional pixels buffer as described in getPixels().

RgbImage

public RgbImage(String location)
         throws IOException
Creates an image reading the given URL.
Actually reads GIF, PNG and JPG formats

Throws:
IOException
Method Detail

getChannel

public RgbImage getChannel(String channel)
Returns maps of some image channels.

Parameters:
channel - Channel name:
red0x000000RR red value of the pixel
green0x000000GG green value of the pixel
blue0x000000BB blue value of the pixel
intensityIntensity value of the pixel
saturationSaturation, the 0-100% RGB min/max ratio
hueHue i.e. the Smith hexagonal pyramid angle 0-180 in deg/2:
RedYellowGreenCyan BlueMagenta
0 deg/260 deg/2120 deg/2180 deg/2 240 deg/2300 deg/2
monochromeIntensity value of the pixel in the main direction of the color space
binaryIntensity optimal thresholding along the main direction of the color space
Returns:
A RgbImage with a unique ``blue'' channel containing [0-255] values.

getCrop

public RgbImage getCrop(int u,
                        int v,
                        int width,
                        int height)
Returns a sub-image of upper-left corner (u, v) and size (width, height).


getEdgeMap

public RgbImage getEdgeMap(int window,
                           int threshold,
                           String channel)
Returns maps related to the image edges.

Parameters:
window - [optional, default is 2] Smoothing window in pixel.
threshold - [optional, default is 10] Gradient threshold.
channel - Channel name:
contrastContrast (Mexican hat operator)
edgesEdges (gradient magnitude with non maxima suppression)
gradientThresholded gradient magnitude
orientationThresholded gradient orientation in [-Pi/2..Pi/2] returning o = 0.5 * 180 / Pi * orientation + 127
gradientXThresholded gradient horizontal component / 2 + 127
gradientYThresholded gradient vertical component / 2 + 127
curvaturePlessey curvature map
cornersThresholded corners map (Plessey curvature map maxima)
Returns:
A RgbImage with a unique ``blue'' channel containing [0-255] values.

getFiltered

public RgbImage getFiltered(RgbFilter filter)
Returns a filtered image of this.


getGamma

public RgbImage getGamma(double gamma)
Returns a normalized intensity image.

Parameters:
gamma - [optional, default is 2] Intensity correction factor > 1: typically 2; the value 0 corresponds to an intensity equalization. With a value < 0 the image itself is returned without correction.
Returns:
An image with min value at 0 and max value at 255 with a gamma correction in between.

getHeight

public int getHeight()
Gets the image height

Specified by:
getHeight in interface RenderedImage
Overrides:
getHeight in class BufferedImage

getNoisy

public RgbImage getNoisy(double magnitude)
Returns an image with an additional Gaussian noise.

Parameters:
magnitude - Gaussian noise magnitude

getPixels

public int[] getPixels()
Gets the image pixels The [width*height] image buffer contains row by row pixels of the form 0xRRGGBB where RR, GG and BB are red, green and blue byte values.


getRectification

public RgbImage getRectification(double[] H)
Returns a geometrically rectification of the image.

Parameters:
H - affine/projective transformation matrix.

getRegions

public int[] getRegions(int window,
                        int threshold)
Returns a region's map of the image.
Generates the index region map of homogeneous intensity using the Fairfield ``toboggan'' method.

Parameters:
window - [optional, default is 2] Smoothing window in pixel.
threshold - [optional, default is 10] Gradient threshold.
Returns:
An index map, each pixel of the same region having the same index.

getScaled

public RgbImage getScaled(int size)
Returns an image of lower/higher size (multi-scaling).

Parameters:
size - Size factor:
  • If positive the returned image size is [width*|size| x height*|size|]
  • If negative the returned image size is [width/size x height/size]

getSmooth

public RgbImage getSmooth(int window)
Returns a smoothed image.

Parameters:
window - Smoothing window in pixel, default is 2.

getWidth

public int getWidth()
Gets the image width

Specified by:
getWidth in interface RenderedImage
Overrides:
getWidth in class BufferedImage

save

public void save(String location)
          throws IOException
Saves the image in an URL.
Actually writes PNG formats

Throws:
IOException

subtract

public RgbImage subtract(double lambda,
                         double mu,
                         RgbImage val)
Returns an image whose values are (lambda this - mu val) for each pixel.

Parameters:
lambda - Multiplicative factor, default is 1.
mu - Multiplicative factor, default is 1.
val - An image of the same size.

toString

public String toString()
Returns a string view of the image with size and basic parameters as a string.

Overrides:
toString in class BufferedImage