no.hiof.imagepr
Class HSIImage

java.lang.Object
  extended byno.hiof.imagepr.HSIImage
All Implemented Interfaces:
Image, java.io.Serializable

public class HSIImage
extends java.lang.Object
implements Image, java.io.Serializable

An HSIImage is an image using the HSI colour model, which means that each pixel has hue, saturation and intensity components. This class contains methods for setting and getting the HSI components, for transformation between HSI and RGB colour models and for displaying the image and it's HSI components.

All of the components (hue, saturation and intensity) must be in the interval 0 to 255. The hue component is circular, which means that the hue value for 0 and 255 is identical.

Author:
Per-Olav Rusås
See Also:
RGBImage, IntensityImage, BinaryImage, Serialized Form

Field Summary
protected  short[][] hue
          The Matrix with the hue component of the image.
protected  short[][] intensity
          The Matrix with the intensity component of the image.
static int L
          The maximum number of levels in each matrix.
protected  short[][] saturation
          The Matrix with the saturation component of the image.
 
Fields inherited from interface no.hiof.imagepr.Image
BLUE, GREEN, RED
 
Constructor Summary
HSIImage()
          Creates an empty HSIImage object.
HSIImage(HSIImage otherImage)
          A copy constructor which copies another HSIImage.
HSIImage(RGBImage image)
          Creates an HSIImage by converting a RGBImage.
HSIImage(short[][] hue, short[][] saturation, short[][] intensity)
          A constructor that sets the HSI matrices
 
Method Summary
 void adjustIntensity()
          Adjust the intensity, so that it doesn't have impossible values.
 Image createScaledImage(double scale, int interpolType)
          Creates a scaled image.
 void draw(java.awt.Graphics g, int x, int y)
          Draw the image to a Graphics object at a given position.
 void draw(java.awt.Graphics g, int x, int y, double scaleX, double scaleY, double rotateAngle)
          Draw the image to a Graphics object at a given position with a given scale and rotation.
 void fromRGBImage(RGBImage image)
          calculats the HSI components from the RGB components of a RGBImage.
 int getHeight()
          The height of the image.
 short[][] getHue()
          Gets the reference to the matrix with the hue component of the image.
 short[][] getIntensity()
          Gets the reference to the matrix with the intensity component of the image.
 short[][] getSaturation()
          Gets the reference to the matrix with the saturation component of the image.
 int getWidth()
          The width of the image.
 java.awt.image.BufferedImage makeBufferedImage()
          Creates a bufferedImage of the HSIImage.
 RGBImage makeRGBImage()
          Makes a RGBImage of the HSIImage.
 void maximizeIntensity()
          Set the intensity to its maximum possible value while maintaining hue and saturation
static double maxIntensity(double hue, double sat)
          Find the maximum intensity possible given a hue and saturation, all in the interval [0,1].
 void setHue(short[][] hue)
          Sets the hue component of the image.
 void setIntensity(short[][] intensity)
          Sets the intensity component of the image.
 void setSaturation(short[][] saturation)
          Sets the saturation component of the image.
 void show()
          Shows the HSIImage in a modal window.
 void show(java.lang.String title)
          Shows the HSIImage in a modal window.
 void show(java.lang.String title, double scale)
          Shows the HSIImage scaled with use of nearest neighbor interpolation.
 void showBL(double scale, java.lang.String title)
          Shows the HSIImage scaled with use of bilinear interpolation.
 void showHue()
          Shows the hue component as an intensity image.
 void showHue(java.lang.String title)
          Shows the hue component as an intensity image.
 void showIntensity()
          Shows the Intensity component as an intensity image.
 void showIntensity(java.lang.String title)
          Shows the Intensity component as an intensity image.
 void showSaturation()
          Shows the saturation component as an intensity image.
 void showSaturation(java.lang.String title)
          Shows the saturation component as an intensity image.
 java.lang.String toString()
          Returns a description of the image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

L

public static final int L
The maximum number of levels in each matrix.

See Also:
Constant Field Values

hue

protected short[][] hue
The Matrix with the hue component of the image.


saturation

protected short[][] saturation
The Matrix with the saturation component of the image.


intensity

protected short[][] intensity
The Matrix with the intensity component of the image.

Constructor Detail

HSIImage

public HSIImage()
Creates an empty HSIImage object.


HSIImage

public HSIImage(RGBImage image)
Creates an HSIImage by converting a RGBImage.

Parameters:
image - RGBImage to be converted.

HSIImage

public HSIImage(short[][] hue,
                short[][] saturation,
                short[][] intensity)
A constructor that sets the HSI matrices

Parameters:
hue - The hue component of the image.
saturation - The saturation component of the image.
intensity - The intensity component of the image.

HSIImage

public HSIImage(HSIImage otherImage)
A copy constructor which copies another HSIImage.

Parameters:
otherImage - Another HSIImage.
Method Detail

getHue

public short[][] getHue()
Gets the reference to the matrix with the hue component of the image. This method does not make a copy of the matrix, but returns the reference to the HSIImage's hue matrix. This means that the returned reference can be used to manipulate the hue of the HSIImage.

Returns:
The hue matrix.

getSaturation

public short[][] getSaturation()
Gets the reference to the matrix with the saturation component of the image. This method does not make a copy of the matrix, but returns the reference to the HSIImage's saturation matrix. This means that the returned reference can be used to manipulate the saturation of the HSIImage.

Returns:
The saturation matrix.

getIntensity

public short[][] getIntensity()
Gets the reference to the matrix with the intensity component of the image. This method does not make a copy of the matrix, but returns the reference to the HSIImage's intensity matrix. This means that the returned reference can be used to manipulate the intensity of the HSIImage.

Returns:
The intensity colour matrix.

setHue

public void setHue(short[][] hue)
Sets the hue component of the image.

Parameters:
hue - Matrix with the hue values.

setSaturation

public void setSaturation(short[][] saturation)
Sets the saturation component of the image.

Parameters:
saturation - Matrix with the saturation values.

setIntensity

public void setIntensity(short[][] intensity)
Sets the intensity component of the image.

Parameters:
intensity - Matrix with the intensity colour values.

getWidth

public int getWidth()
The width of the image. If some of the matrices are missing, the method returns -1.

Specified by:
getWidth in interface Image
Returns:
The width of the image if all the matrices exist.

getHeight

public int getHeight()
The height of the image. If some of the matrixes are missing, the method returns -1.

Specified by:
getHeight in interface Image
Returns:
The height of the image if all the matrices exist.

fromRGBImage

public void fromRGBImage(RGBImage image)
calculats the HSI components from the RGB components of a RGBImage.

Parameters:
image - The RGB source image.

makeRGBImage

public RGBImage makeRGBImage()
Makes a RGBImage of the HSIImage.

Returns:
A HSIImage converted into a RGBImage

show

public void show(java.lang.String title)
Shows the HSIImage in a modal window.

Specified by:
show in interface Image
Parameters:
title - The title on top of the window.

show

public void show()
Shows the HSIImage in a modal window.


show

public void show(java.lang.String title,
                 double scale)
Shows the HSIImage scaled with use of nearest neighbor interpolation. This method utilizes an ImageScaler to perform the scaling.

Specified by:
show in interface Image
Parameters:
title - The title on top of the window.
scale - The scale.

showBL

public void showBL(double scale,
                   java.lang.String title)
Shows the HSIImage scaled with use of bilinear interpolation. This method utilizes an ImageScaler to perform the scaling.

Parameters:
scale - The scale.
title - The title on top of the window.

showHue

public void showHue()
Shows the hue component as an intensity image.


showSaturation

public void showSaturation()
Shows the saturation component as an intensity image.


showIntensity

public void showIntensity()
Shows the Intensity component as an intensity image.


showHue

public void showHue(java.lang.String title)
Shows the hue component as an intensity image.


showSaturation

public void showSaturation(java.lang.String title)
Shows the saturation component as an intensity image.


showIntensity

public void showIntensity(java.lang.String title)
Shows the Intensity component as an intensity image.


createScaledImage

public Image createScaledImage(double scale,
                               int interpolType)
Creates a scaled image. This method utilizes an ImageScaler to perform the scaling. The parameter interpolType may be one of the constants RGBImage.NN_INTERPOL for nearest neighbor interpolation or RGBImage.BL_INTERPOL for bilinear interpolation.

Specified by:
createScaledImage in interface Image
Parameters:
scale - The scale.
interpolType - The type of interpolation

draw

public void draw(java.awt.Graphics g,
                 int x,
                 int y)
Draw the image to a Graphics object at a given position.

Specified by:
draw in interface Image
Parameters:
g - The Graphics object to draw on.
x - The horizontal position of the image.
y - The vertical position of the image.

draw

public void draw(java.awt.Graphics g,
                 int x,
                 int y,
                 double scaleX,
                 double scaleY,
                 double rotateAngle)
Draw the image to a Graphics object at a given position with a given scale and rotation.

Specified by:
draw in interface Image
Parameters:
g - The Graphics object to draw on.
x - The horizontal position of the image.
y - The vertical position of the image.
scaleX - The scale in x-direction. 1.0 means unscaled.
scaleY - The scale in y-direction. 1.0 means unscaled.
rotateAngle - Rotation of the image in degrees (0-360).

makeBufferedImage

public java.awt.image.BufferedImage makeBufferedImage()
Creates a bufferedImage of the HSIImage.

Specified by:
makeBufferedImage in interface Image
Returns:
a BufferedImage version of the Image

toString

public java.lang.String toString()
Returns a description of the image.

Returns:
A description.

maxIntensity

public static double maxIntensity(double hue,
                                  double sat)
Find the maximum intensity possible given a hue and saturation, all in the interval [0,1].

Parameters:
hue - Hue
sat - Saturation
Returns:
Maximum intensity

adjustIntensity

public void adjustIntensity()
Adjust the intensity, so that it doesn't have impossible values. May be called after adjusting hue or saturation. If the intensity of a point is to high, the intensity is adjusted to the highest possible value while maintaining the hue and saturation.


maximizeIntensity

public void maximizeIntensity()
Set the intensity to its maximum possible value while maintaining hue and saturation