|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectno.hiof.imagepr.RGBImage
RGBImage is a class for images which is supposed to be easier to use than the classes for image processing in the Java SDK API. The RGImage class contains three two-dimensional short arrays (matrices) called red green and blue which contains the pixel values of the image. Other colours then the three primary colours are composed as a combination of red, green and blue.
In order to be viewed properly, the colour values must be set in the interval from 0 to 255.
The RGBImage class contains methods for setting and getting the color matrices, showing the image, saving the image to a file and reading the images from a file or from a web-location.
IntensityImage
,
BinaryImage
,
HSIImage
,
Serialized FormField Summary | |
protected short[][] |
blue
The Matrix with the blue component of the image |
protected short[][] |
green
The Matrix with the green component of the image |
protected int |
imageType
The image type used when saving the image. |
protected short[][] |
red
The Matrix with the red component of the image |
Fields inherited from interface no.hiof.imagepr.Image |
BLUE, GREEN, RED |
Constructor Summary | |
RGBImage()
A constructor that creates an empty RGBImage object. |
|
RGBImage(BinaryImage binImage)
A constructor which creates an image based on a BinaryImage (black and white image). |
|
RGBImage(java.awt.image.BufferedImage bim)
A constructor which creates an image based on a BufferedImage. |
|
RGBImage(HSIImage hsiImage)
A constructor which creates an image based on a HSIImage. |
|
RGBImage(IntensityImage intensImage)
A constructor which creates an image based on an IntensityImage (gray scale image). |
|
RGBImage(int rows,
int cols)
A constructor that creates a black image of given size. |
|
RGBImage(RGBImage otherImage)
A constructor which copy another RGBImage. |
|
RGBImage(short[][] red,
short[][] green,
short[][] blue)
A constructor that sets the color matrices. |
|
RGBImage(java.lang.String location)
A constructor which read an image from an URL or a file. |
Method Summary | |
void |
copyFrom(RGBImage otherImage)
Copy another RGBImage. |
Image |
createScaledImage(double scale,
int interpolType)
Creates a scaled image. |
void |
draw(java.awt.Graphics g,
int x,
int y)
Draws 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)
Draws the image to a Graphics object at a given position with a given scale and rotation. |
short[][] |
getBlue()
Gets the reference to the matrix with the blue colour component of the image. |
short[][] |
getGreen()
Gets the reference to the matrix with the green colour component of the image. |
int |
getHeight()
The height of the image. |
short[][] |
getRed()
Gets the reference to the matrix with the red colour component of the image. |
int |
getWidth()
The width of the image. |
void |
loadFile(java.lang.String filename)
Load an image from a file. |
void |
loadURL(java.lang.String url)
Load an image from a URL. |
java.awt.image.BufferedImage |
makeBufferedImage()
Make a BufferedImage of the RGBImage based on the contents of the RGBImage. |
boolean |
rgbEqual()
Returns true if the R, G and B components are all equal, which means that the image is a gray scale image. |
void |
save(java.lang.String filename)
Saves the image to a file. |
void |
saveAsJPEG(java.lang.String filename,
double quality)
Saves the image to a JPEG-file. |
void |
setBImage(java.awt.image.BufferedImage bImage)
Set the BufferedImage of the RGBImage. |
void |
setBlue(short[][] blue)
Sets the blue component of the image. |
void |
setGreen(short[][] green)
Sets the green component of the image. |
void |
setRed(short[][] red)
Sets the red component of the image. |
void |
show()
Shows a JOptionPane-window including the image. |
void |
show(java.lang.String title)
Shows a JOptionPane-window including the image. |
void |
show(java.lang.String title,
double scale)
Shows the RGBImage scaled with use of nearest neighbor interpolation. |
void |
showBL(java.lang.String title,
double scale)
Shows the RGBImage scaled with use of bilinear interpolation. |
java.lang.String |
toString()
Returns a description of the image. |
void |
useGrayColormap()
Force the image to be shown with a colormap usually used for gray scale images. |
void |
useRGBColormap()
Force the image to be shown with a colormap usually used for color images. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected short[][] red
protected short[][] green
protected short[][] blue
protected int imageType
Constructor Detail |
public RGBImage()
public RGBImage(int rows, int cols)
rows
- Number of rows.cols
- Number of colums.public RGBImage(short[][] red, short[][] green, short[][] blue)
red
- The red component of the image.green
- The green component of the image.blue
- The blue component of the image.public RGBImage(RGBImage otherImage)
otherImage
- Another RGBImage.public RGBImage(IntensityImage intensImage)
intensImage
- Original imagepublic RGBImage(BinaryImage binImage)
binImage
- Original imagepublic RGBImage(HSIImage hsiImage)
hsiImage
- Original imagepublic RGBImage(java.awt.image.BufferedImage bim)
bim
- Original imagepublic RGBImage(java.lang.String location) throws java.io.IOException
location
- The URL or filenameMethod Detail |
public void copyFrom(RGBImage otherImage)
otherImage
- Image to copypublic short[][] getRed()
public short[][] getGreen()
public short[][] getBlue()
public void setRed(short[][] red)
red
- Matrix with the red colour values.public void setGreen(short[][] green)
green
- Matrix with the green colour values.public void setBlue(short[][] blue)
blue
- Matrix with the blue colour values.public boolean rgbEqual()
public int getWidth()
getWidth
in interface Image
public int getHeight()
getHeight
in interface Image
public java.lang.String toString()
public void setBImage(java.awt.image.BufferedImage bImage)
bImage
- the BufferedImage.public java.awt.image.BufferedImage makeBufferedImage()
makeBufferedImage
in interface Image
public void loadURL(java.lang.String url) throws java.io.IOException
url
- the URL of the web-location containing an image file
java.io.IOException
public void loadFile(java.lang.String filename) throws java.io.IOException
filename
- The name of the image file.
java.io.IOException
public void save(java.lang.String filename) throws java.io.IOException
filename
- the name of the file.
java.io.IOException
public void saveAsJPEG(java.lang.String filename, double quality) throws java.io.IOException
filename
- the name of the file.quality
- the quality of the image, between 0.0 and 1.0
java.io.IOException
public void draw(java.awt.Graphics g, int x, int y)
draw
in interface Image
g
- The Graphics object to draw on.x
- The horizontal position of the image.y
- The vertical position of the image.public void draw(java.awt.Graphics g, int x, int y, double scaleX, double scaleY, double rotateAngle)
draw
in interface Image
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).public void show(java.lang.String title)
show
in interface Image
title
- A text placed on the bar on top of the window.public void show()
public void show(java.lang.String title, double scale)
show
in interface Image
scale
- The scale.title
- The title on top of the window.public void showBL(java.lang.String title, double scale)
scale
- The scale.title
- The title on top of the window.public Image createScaledImage(double scale, int interpolType)
createScaledImage
in interface Image
scale
- The scale.interpolType
- The type of interpolationpublic void useGrayColormap()
public void useRGBColormap()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |