Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

ImageRGB Class Reference

An image consisting of red, green and blue pixels. More...

#include <ImageRGB.h>

Inheritance diagram for ImageRGB::

ImageBase Image ImageHSV List of all members.

Public Types

enum  FieldSelector { RED, GREEN, BLUE }
 Field selectors for field based methods. More...


Public Methods

 ImageRGB (unsigned int width, unsigned int height)
 Create an image with the given dimensions. More...

 ImageRGB (char *, FileFormat)
 Create an image from a graphics file. More...

 ImageRGB (ImageRGB &)
 Copy Constructor. More...

 ImageRGB (ImageRGB &, unsigned int min_x, unsigned int min_y, unsigned int max_x, unsigned int max_y)
 Create an image from a portion of another image. More...

 ~ImageRGB ()
 Destructor for ImageRGB class. More...

void set_pixel (unsigned int x, unsigned int y, PixelRGB p)
 set the value of a pixel specified by (x,y). More...

void set_rgb (unsigned int x, unsigned int y, int red, int green, int blue)
 Set the red, green and blue values of a pixel specified by (x,y). More...

void set_field (unsigned int x, unsigned int y, FieldSelector, int value)
 Set the selected fields value of a pixel specified by (x,y). More...

void get_pixel (unsigned int x, unsigned int y, PixelRGB &p)
 Return the red, green and blue values of the pixel specified by (x,y) in p. More...

int get_field (unsigned int x, unsigned int y, FieldSelector)
 Return the selected fields value of a pixel specified by (x,y). More...

ImageRGB& clear (int=0)
 Set to value (clear) all of the pixels in the image. More...

ImageRGB& clear (PixelRGB &)
 Set all of the pixels in the image to the specified value. More...

ImageRGB& clear_field (FieldSelector, int=0)
 Set to value (clear) all values in the selected field. More...

ImageRGB& copy (ImageRGB &img)
 Copy data from from img. More...

ImageRGB& copy (ImageRGB &img, unsigned int min_x, unsigned int min_y, unsigned int max_x, unsigned int max_y, unsigned int start_x, unsigned int start_y)
 Copy block of data from img. More...

bool save (char *, FileFormat)
 Save in graphics file format. More...

ImageRGB& operator= (ImageRGB &img)
 Overload equals (=) operator for two images.

bool draw_line (int x_start, int y_start, int x_end, int y_end, PixelRGB pix)
 Method draws a straight line from point (x_start,y_start) to (x_end,y_end) of colour described by PixelRGB pix. More...

bool draw_filled_circle (unsigned int centre_x, unsigned int centre_y, unsigned int radius, PixelRGB pix)
 Method draws a filled circle with centre at point (centre_x,centre_y) of radius radius and colour described by PixelRGB pix. More...

bool enhance_contrast ()
 Enhances contrast in image by stretching RGB to full range using a linear multiplier.

void normalise_colourspace (int scale_factor)
 Normalises the colourspace by dividing all RGB values by R+G+B and multiplying by scale_factor.

void quick_grey_and_scale_down (unsigned int scale_fact, ImageGrey &img)
 Combined integer scale down (sub-sampling) and greyscale conversion.

void histogram_segment (Histogram &hist, float threshold, ImageRGB &result)
 Produces a binary image based on the image and the colour histogram 'hist'. More...

void histogram_segment (Histogram &hist, float threshold, bool *result)
 Produces a binary image based on the image and the colour histogram 'hist'. More...


Public Attributes

PixelRGBdata
 RGB image data.


Detailed Description

An image consisting of red, green and blue pixels.

The image is stored as an array of ints, each pixel spanning three ints (one for each of its red, green and blue values).

Definition at line 30 of file ImageRGB.h.


Member Enumeration Documentation

enum ImageRGB::FieldSelector
 

Field selectors for field based methods.

Enumeration values:
RED   Select the red field so the operation is only performed on the red values of the image data.
GREEN   Select the green field so the opertion is only performed on the green values of the image data.
BLUE   Select the blue field so the operation is only performed on the blue values of the image data.

Definition at line 40 of file ImageRGB.h.


Constructor & Destructor Documentation

ImageRGB::ImageRGB ( unsigned int width,
unsigned int height )
 

Create an image with the given dimensions.

Sets the parameters Width and Height to the inputs width and height.

Parameters:
w   The Width of the image.
h   The Height of the image.

Definition at line 62 of file ImageRGB.cpp.

ImageRGB::ImageRGB ( char * filename,
FileFormat format )
 

Create an image from a graphics file.

Sets the parameters Width and Height to the inputs width and height.

Parameters:
filename   The name of the image file.
FileFormat   The format of the image file.

Definition at line 78 of file ImageRGB.cpp.

ImageRGB::ImageRGB ( ImageRGB & img )
 

Copy Constructor.

Parameters:
img   The RGBImage to copy

Definition at line 31 of file ImageRGB.cpp.

ImageRGB::ImageRGB ( ImageRGB & img,
unsigned int min_x,
unsigned int min_y,
unsigned int max_x,
unsigned int max_y )
 

Create an image from a portion of another image.

Parameters:
img   The RGBImage to copy
min_x   Minimum extent of block to copy (X)
min_y   Minimum extent of block to copy (Y)
max_x   Maximum extent of block to copy (X)
max_y   Maximum extent of block to copy (Y)

Definition at line 44 of file ImageRGB.cpp.

ImageRGB::~ImageRGB ( )
 

Destructor for ImageRGB class.

Frees memory allocated to array:

Definition at line 167 of file ImageRGB.cpp.


Member Function Documentation

ImageRGB & ImageRGB::clear ( PixelRGB & p )
 

Set all of the pixels in the image to the specified value.

Parameters:
p   Pixel to set to.

Definition at line 285 of file ImageRGB.cpp.

ImageRGB & ImageRGB::clear ( int k = 0 )
 

Set to value (clear) all of the pixels in the image.

Parameters:
k   Value to clear the field to.

Definition at line 269 of file ImageRGB.cpp.

Referenced by Image::clear_rgb().

ImageRGB & ImageRGB::clear_field ( FieldSelector fs,
int k = 0 )
 

Set to value (clear) all values in the selected field.

Parameters:
k   Value to clear the field to.
fs   The field so clear, one of (RED, GREEN, BLUE).

Definition at line 305 of file ImageRGB.cpp.

ImageRGB & ImageRGB::copy ( ImageRGB & img,
unsigned int min_x,
unsigned int min_y,
unsigned int max_x,
unsigned int max_y,
unsigned int start_x,
unsigned int start_y )
 

Copy block of data from img.

Throws an exception if img is of incorrect size.

Parameters:
img   The image to copy the data from.
min_x   Minimum extent of block to copy (X)
min_y   Minimum extent of block to copy (Y)
max_x   Maximum extent of block to copy (X)
max_y   Maximum extent of block to copy (Y)
start_x   Start location (top left) for destination (X)
start_y   Start location (top left) for destination (Y)

Definition at line 344 of file ImageRGB.cpp.

ImageRGB & ImageRGB::copy ( ImageRGB & img )
 

Copy data from from img.

Throws an exception if images are of different size.

Parameters:
img   The image to copy the data from.

Definition at line 322 of file ImageRGB.cpp.

Referenced by ImageRGB(), Image::copy(), operator=(), and Image::operator=().

bool ImageRGB::draw_filled_circle ( unsigned int centre_x,
unsigned int centre_y,
unsigned int radius,
PixelRGB pix )
 

Method draws a filled circle with centre at point (centre_x,centre_y) of radius radius and colour described by PixelRGB pix.

The method returns false if any point is outside the image.

Reimplemented in Image.

Definition at line 278 of file Image-draw.cpp.

Referenced by Image::draw_filled_circle().

bool ImageRGB::draw_line ( int x_start,
int y_start,
int x_end,
int y_end,
PixelRGB pix )
 

Method draws a straight line from point (x_start,y_start) to (x_end,y_end) of colour described by PixelRGB pix.

The method returns false if either point is outside the image.

Reimplemented in Image.

Definition at line 127 of file Image-draw.cpp.

Referenced by Image::draw_line().

int ImageRGB::get_field ( unsigned int x,
unsigned int y,
FieldSelector fs )
 

Return the selected fields value of a pixel specified by (x,y).

Note:
No check is made that x and y are in range.
Parameters:
x,y   The coordinates of the pixel.

Returns:
The selected fields value.

Definition at line 254 of file ImageRGB.cpp.

void ImageRGB::get_pixel ( unsigned int x,
unsigned int y,
PixelRGB & p )
 

Return the red, green and blue values of the pixel specified by (x,y) in p.

Note:
No check is made that x and y are in range.
Parameters:
x,y   The coordinates of the pixel.
p   A Reference to the pixel to store the values in.

Definition at line 236 of file ImageRGB.cpp.

Referenced by Image::get_rgb().

void ImageRGB::histogram_segment ( Histogram & hist,
float threshold,
bool * result )
 

Produces a binary image based on the image and the colour histogram 'hist'.

If the probability of a given colour in the histogram is greater than a threshold the corresponding pixel in 'result' is set true, otherwise the pixel is set false.

Definition at line 566 of file ImageRGB.cpp.

void ImageRGB::histogram_segment ( Histogram & hist,
float threshold,
ImageRGB & result )
 

Produces a binary image based on the image and the colour histogram 'hist'.

If the probability of a given colour in the histogram is greater than a threshold the corresponding pixel in 'result' is set true (255,255,255), otherwise the pixel is set false (0,0,0).

Definition at line 541 of file ImageRGB.cpp.

bool ImageRGB::save ( char * filename,
FileFormat format )
 

Save in graphics file format.

Parameters:
filename   filname of the file to be created
format   format of file to be created

Definition at line 410 of file ImageRGB.cpp.

void ImageRGB::set_field ( unsigned int x,
unsigned int y,
FieldSelector fs,
int value )
 

Set the selected fields value of a pixel specified by (x,y).

Throws an exception if coordinates are not valid.

Parameters:
x,y   The coordinates of the pixel.
fs   The selected Field.
value   The value to set the field to.

Definition at line 216 of file ImageRGB.cpp.

void ImageRGB::set_pixel ( unsigned int x,
unsigned int y,
PixelRGB p )
 

set the value of a pixel specified by (x,y).

Parameters:
x,y   The coordinates of the pixel
p   The Pixel with values red, green and blue

Definition at line 176 of file ImageRGB.cpp.

Referenced by Image::set_rgb().

void ImageRGB::set_rgb ( unsigned int x,
unsigned int y,
int red,
int green,
int blue )
 

Set the red, green and blue values of a pixel specified by (x,y).

Throws an exception if coordinates are not valid.

Parameters:
x,y   The coordinates of the pixel
red   The value of the RED field
green   The value of the GREEN field
blue   The value of the BLUE field

Definition at line 192 of file ImageRGB.cpp.


The documentation for this class was generated from the following files:
Generated at Fri Aug 13 17:29:22 2004 for libRTImage by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001