public class PixelMap
extends java.lang.Object
implements java.io.Serializable
A pixel map may be created from an image, as a blank map, as a copy of an existing pixel map, or from input related to a particular color image encoding. Allowed encodings are defined in this class, and are used for, eg, choosing the particular colors used in a color map representation of numerical data. The class contains methods which allow setting the value of a pixel, retrieving its value and flood filling areas of pixels.
Images are stored in an integer array. Each element (pixel) of the array stores RGB information in different groups of bits: the lowest 8 bits contains blue, the next highest 8 bits holds green, and the next highest 8 bits red. The highest 8 bits of each int are ignored.
The Triana Color Map model is a one-dimensional list of 256 colors running from red (lowest) to blue (highest). They run through the visible spectrum using rgb colors that are fully saturated and of medium brightness. The color model is designated by the static integer TRIANA_COLOR_MAP and is defined by the static array of rgb values called trianaColorMapTable.
Modifier and Type | Field and Description |
---|---|
int |
height |
int[] |
pixels |
static int |
TRIANA_COLOR_MAP
Defining index for the Triana Color Map model.
|
static int[] |
trianaColorMapTable
Table that defines the 256 rgb values of the Triana Color Map.
|
int |
width |
Constructor and Description |
---|
PixelMap() |
PixelMap(java.awt.Image image)
Creates a PixelMap object of the same dimensions as the given image and tries to include the pixel information of
the image.
|
PixelMap(int[][] colorMatrix,
int model)
Creates a PixelMap object from an input matrix of color values according to the given color map model, as defined
in this class.
|
PixelMap(int width,
int height)
Creates a PixelMap object of the given dimensions and clears the pixel map to all black pixels.
|
PixelMap(int width,
int height,
boolean clear)
Creates a PixelMap object of the given dimensions with the option of clearing the pixel map to all black pixels.
|
PixelMap(PixelMap pixelmap)
Creates a PixelMap object which is a copy of the PixelMap object supplied.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the pixel map to all black pixels.
|
void |
fillBlack(int x,
int y,
int pixel)
Fills a black area to the given colour
|
void |
fillColour(int x,
int y,
int pixel,
int oldpixel)
Flood fills an area of oldpixel values with pixel values starting at coordinate (x, y).
|
void |
fillErase(int x,
int y)
Fills a non black area to black, ie erases the colour
|
ImageHistogram |
getBlueHistogram()
Returns a Histogram object containing the histogram of the values in the blue channel of the image.
|
ImageHistogram |
getGreenHistogram()
Returns a Histogram object containing the histogram for the values in the green channel of the image.
|
int |
getHeight()
Returns the height of the pixel map in pixels.
|
java.awt.image.ImageProducer |
getImageProducer()
Returns an ImageProducer for the data contained within the PixelMap.
|
ImageHistogram |
getIntensityHistogram()
Returns a Histogram object containing the histogram of the intensities of the pixels in the image.
|
int |
getLength()
Returns the size of the pixel map.
|
int |
getPixel(int x,
int y) |
int[] |
getPixels()
Returns the array of pixels.
|
ImageHistogram |
getRedHistogram()
Returns a Histogram object containing the histogram for the values in the red channel of the image.
|
int |
getWidth()
Returns the width of the pixel map in pixels.
|
int |
rgbOfTrianaColorMapColor(int c)
Returns the rgb value of a given color in the Triana Color Map model.
|
void |
setPixel(int x,
int y,
int value) |
int |
trianaColorMapColorOf(int p)
Returns the Triana Color Map color value associated with a given rgb pixel value.
|
public int width
public int height
public int[] pixels
public static int TRIANA_COLOR_MAP
public static int[] trianaColorMapTable
public PixelMap()
public PixelMap(int width, int height, boolean clear)
width
- The width of the mapheight
- The height of the mapclear
- true if the map is to be cleared to black.public PixelMap(int width, int height)
width
- The width of the mapheight
- The height of the mappublic PixelMap(java.awt.Image image)
image
- The given image to be made into the pixel mappublic PixelMap(PixelMap pixelmap)
pixelmap
- The given PixelMap objet.public PixelMap(int[][] colorMatrix, int model)
colorMatrix
- A matrix containing the color values of the modelmodel
- An integer that designates which model is being usedpublic java.awt.image.ImageProducer getImageProducer()
public void clear()
public int getWidth()
public int getHeight()
public int[] getPixels()
public int getLength()
public int getPixel(int x, int y)
public void setPixel(int x, int y, int value)
public int rgbOfTrianaColorMapColor(int c)
c
- The given color value on the Triana Color Map scalepublic int trianaColorMapColorOf(int p)
p
- The rgb value of the given pixelpublic void fillColour(int x, int y, int pixel, int oldpixel)
If uses a scanline method to reduce recursion and increase speed and efficiency.
public void fillBlack(int x, int y, int pixel)
public void fillErase(int x, int y)
public ImageHistogram getRedHistogram()
public ImageHistogram getGreenHistogram()
public ImageHistogram getBlueHistogram()
public ImageHistogram getIntensityHistogram()