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

ImageGrey Class Reference

An image where each pixel consists of a varying level of grey. More...

#include <ImageGrey.h>

Inheritance diagram for ImageGrey::

ImageBase Image List of all members.

Public Methods

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

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

 ImageGrey (ImageGrey &)
 Copy constructor. More...

 ImageGrey (ImageGrey &img, unsigned int min_x, unsigned int min_y, unsigned int max_x, unsigned int max_y)
 Initialise to a new Image and copy over an area of img. More...

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

void set_pixel (unsigned int x, unsigned int y, PixelGrey level)
 Set the grey level value of a pixel specified by (x,y). More...

void get_pixel (unsigned int x, unsigned int y, PixelGrey &p)
 Return the value of the pixel specified by (x,y) in p. More...

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

ImageGrey& copy (ImageGrey &img)
 Copy data from image data from img. More...

ImageGrey& copy (ImageGrey &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 data from block of image data from img. More...

void absolute ()
 Absolute value of brightness.

void threshold (int thresh)
 Threshold brightness. More...

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

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

ImageGrey& operator-= (ImageGrey &img)
 Overload equals (-=) operator for two images. More...

ImageGrey& operator+= (int fact)
 Overload equals (+=) operator for Image and constant. More...

ImageGrey& operator-= (int fact)
 Overload equals (-=) operator for Image and constant. More...

ImageGrey& operator/= (int fact)
 Overload equals (/=) operator for Image and constant. More...

ImageGrey& operator *= (int fact)
 Overload equals (*=) operator for Image and constant. More...

bool draw_line (int x_start, int y_start, int x_end, int y_end, PixelGrey intensity)
 Method draws a straight line from point (x_start,y_start) to (x_end,y_end) of intensity described by brightness in PixelGrey intensity. More...

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

void scale_down (unsigned int min_x, unsigned int min_y, unsigned int max_x, unsigned int max_y, unsigned int new_sx, unsigned int new_sy, float *new_image)
void scale_down (unsigned int min_x, unsigned int min_y, unsigned int max_x, unsigned int max_y, unsigned int new_sx, unsigned int new_sy, double *new_image)
 Scales a section of the image (min_x,min_y -> max_x,max_y) to a new buffer (new_image) of size new_sx*new_sy Scales by calculating the centre of scaled down point in original frame of reference and using a gaussian window.

void quick_scale_down (unsigned int min_x, unsigned int min_y, unsigned int max_x, unsigned int max_y, unsigned int new_sx, unsigned int new_sy, double *new_image)
 Scales a section of the image (min_x,min_y -> max_x,max_y) to a new buffer (new_image) of size new_sx*new_sy Scales by calculating the centre of scaled down point in original frame of reference and using a gaussian window.

float convolve (unsigned int x, unsigned int y, CMatrix *conv_matrix)
 Convolve image with a kernel. More...

void plot_conv_kernel (unsigned int x, unsigned int y, CMatrix *conv_matrix, float scale_fact, float offset)
 Draws convolution kernel into image (for debug and visualisation). More...

float wavelet_convolve (unsigned int x, unsigned int y, Wavelet *wavelet, float *real, float *imag)
 Performs convolutions with real and imaginary wavelet kernels. More...

void blur (unsigned int size, ImageGrey &result)
 Blurs image by convolving with a matrix of equal values (1/(size*size)) of size size*size. More...

bool sobel_horizontal (ImageGrey &result)
 Performs a horizontal sobel edge detection. More...

bool sobel_vertical (ImageGrey &result)
 Performs a vertical sobel edge detection. More...

bool sobel (ImageGrey &result)
 Performs a sobel (horizontal and vertical) edge detection. More...

bool median (unsigned int n, unsigned int m, ImageGrey &result)
 Method performs a median filter on image over an nxm neighbourhood. More...

bool dilate (ImageGrey &result)
 This method dilates the image by examining a 3x3 grid around all black pixels. More...

bool erode (ImageGrey &result)
 This method errodes the image by examining a 3x3 grid around all white pixels. More...

bool errode (ImageGrey &result)
 Method included for back-compatibility.

bool remove_point_noise (ImageGrey &result)
 Method to remove isolated points from a binary image, result is stored in an object referenced by result.

bool region_identify (unsigned int max_regions, unsigned int &actual_regions, ImageGrey &result)
 This method divides a binary image into spatially connected regions using the method described in "image processing, analysis and machine vision, Sonka, Hlavac and Boyle, pp197-8. More...

bool extract_region (int, ImageGrey &result)
 Method to extract area where intensity value is region_no. More...

void normalise_intensity (float mean, float sd)
 Calculates and normalises intensity values to specified mean and standard deviation. More...

void normalise_intensity_range ()
 Normalises intensity by adjusting min / max range to 0 -> 255 NOTE: Leaves image unchanged if all brightness values equal.


Public Attributes

PixelGreybrightness
 Greyscale image data.


Detailed Description

An image where each pixel consists of a varying level of grey.

The image is stored as an array of ints, each pixel represented as a single int.

Definition at line 39 of file ImageGrey.h.


Constructor & Destructor Documentation

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

Create an image with the given dimensions.

Parameters:
w   The width of the image.
h   The height of the image.

Definition at line 52 of file ImageGrey.cpp.

ImageGrey::ImageGrey ( 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 66 of file ImageGrey.cpp.

ImageGrey::ImageGrey ( ImageGrey & img )
 

Copy constructor.

Parameters:
img   The image to copy

Definition at line 38 of file ImageGrey.cpp.

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

Initialise to a new Image and copy over an area of img.

Parameters:
img   The Image 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 158 of file ImageGrey.cpp.

ImageGrey::~ImageGrey ( )
 

Destructor for ImageGrey class.

Frees memory allocated to array:

Definition at line 178 of file ImageGrey.cpp.


Member Function Documentation

void ImageGrey::blur ( unsigned int size,
ImageGrey & result )
 

Blurs image by convolving with a matrix of equal values (1/(size*size)) of size size*size.

Parameters:
size   X and Y size of blur convolution matrix (should be odd)
result   Image to store result in.

Definition at line 185 of file ImageGrey-conv.cpp.

ImageGrey & ImageGrey::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 219 of file ImageGrey.cpp.

Referenced by Image::clear_brightness().

float ImageGrey::convolve ( unsigned int x,
unsigned int y,
CMatrix * conv_matrix )
 

Convolve image with a kernel.

N.B. No check is made on the validity of the kernel centre w.r.t. kernel and image size.

Parameters:
x   X co-ordinate of kernel centre in image
y   Y co-ordinate of kernel centre in image
kernel   Convolution kernel

Definition at line 29 of file ImageGrey-conv.cpp.

ImageGrey & ImageGrey::copy ( ImageGrey & 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 data from block of image 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 257 of file ImageGrey.cpp.

ImageGrey & ImageGrey::copy ( ImageGrey & img )
 

Copy data from image data from img.

Throws an exception if images are of different size.

Parameters:
img   The image to copy the brightness from.

Definition at line 235 of file ImageGrey.cpp.

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

bool ImageGrey::dilate ( ImageGrey & result )
 

This method dilates the image by examining a 3x3 grid around all black pixels.

If any pixel in this grid is true the pixel is set true. The result is stored in the object 'result'. The method returns false is either object is invalid or the objects are of different sizes.

Definition at line 720 of file ImageGrey.cpp.

bool ImageGrey::draw_filled_circle ( unsigned int centre_x,
unsigned int centre_y,
unsigned int radius,
PixelGrey intensity )
 

Method draws a filled circle with centre at point (centre_x,centre_y) of radius radius and brightness described by PixelGrey intensity.

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

Reimplemented in Image.

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

Referenced by Image::draw_filled_circle().

bool ImageGrey::draw_line ( int x_start,
int y_start,
int x_end,
int y_end,
PixelGrey intensity )
 

Method draws a straight line from point (x_start,y_start) to (x_end,y_end) of intensity described by brightness in PixelGrey intensity.

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

Reimplemented in Image.

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

Referenced by Image::draw_line().

bool ImageGrey::erode ( ImageGrey & result )
 

This method errodes the image by examining a 3x3 grid around all white pixels.

If any pixel in this grid is false the pixel is set false. The result is stored in the object pointed to by result. The method returns false is either object is invalid or the objects are of different sizes.

Definition at line 785 of file ImageGrey.cpp.

bool ImageGrey::extract_region ( int region_no,
ImageGrey & result )
 

Method to extract area where intensity value is region_no.

All other areas are set to zero (background). Result is stored in the object pointed to by result. Note: Works on image generated by region_identify(). Region 0 = background, region 1 = largest region, region 2 = second largest etc.

Definition at line 842 of file ImageGrey.cpp.

void ImageGrey::get_pixel ( unsigned int x,
unsigned int y,
PixelGrey & p )
 

Return the value 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   Reference to the Pixel to store the pixels value in.

Definition at line 205 of file ImageGrey.cpp.

Referenced by Image::get_brightness().

bool ImageGrey::median ( unsigned int n,
unsigned int m,
ImageGrey & result )
 

Method performs a median filter on image over an nxm neighbourhood.

The result is stored in an object referenced by result.

Definition at line 1232 of file ImageGrey.cpp.

void ImageGrey::normalise_intensity ( float mean,
float sd )
 

Calculates and normalises intensity values to specified mean and standard deviation.

Parameters:
mean   Requested mean
sd   Requested standard deviation

Definition at line 1156 of file ImageGrey.cpp.

ImageGrey & ImageGrey::operator *= ( int fact )
 

Overload equals (*=) operator for Image and constant.

Parameters:
fact   Multiplication constant

Definition at line 363 of file ImageGrey.cpp.

ImageGrey & ImageGrey::operator+= ( int fact )
 

Overload equals (+=) operator for Image and constant.

Parameters:
fact   Addition constant

Definition at line 321 of file ImageGrey.cpp.

ImageGrey & ImageGrey::operator-= ( int fact )
 

Overload equals (-=) operator for Image and constant.

Parameters:
fact   Subtraction constant

Definition at line 342 of file ImageGrey.cpp.

ImageGrey & ImageGrey::operator-= ( ImageGrey & img )
 

Overload equals (-=) operator for two images.

Parameters:
img   The image to be subtracted

Definition at line 406 of file ImageGrey.cpp.

ImageGrey & ImageGrey::operator/= ( int fact )
 

Overload equals (/=) operator for Image and constant.

Parameters:
fact   Division constant

Definition at line 384 of file ImageGrey.cpp.

void ImageGrey::plot_conv_kernel ( unsigned int x,
unsigned int y,
CMatrix * conv_matrix,
float scale_fact,
float offset )
 

Draws convolution kernel into image (for debug and visualisation).

N.B. No check is made on the validity of the kernel centre w.r.t. kernel and image size.

Parameters:
x   X co-ordinate of kernal centre in image
y   Y co-ordinate of kernal centre in image
kernel   Convolution kernel
scale_fact   Multiplier for kernel values
offset   Offset for kernel values

Definition at line 103 of file ImageGrey-conv.cpp.

bool ImageGrey::region_identify ( unsigned int max_regions,
unsigned int & actual_regions,
ImageGrey & result )
 

This method divides a binary image into spatially connected regions using the method described in "image processing, analysis and machine vision, Sonka, Hlavac and Boyle, pp197-8.

Background pixels are left zero / false and other pixels set to 1->max_regions depending on what region they belong to. If the no. of regions exceeds max_regions the smallest regions are discarded and their pixels set to zero. The method returns false if either object is invalid or result is a different size or max_regions is negative. The no. of actual regions found (excluding 'background') is returned in actual_regions.

Definition at line 877 of file ImageGrey.cpp.

bool ImageGrey::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 471 of file ImageGrey.cpp.

void ImageGrey::set_pixel ( unsigned int x,
unsigned int y,
PixelGrey level )
 

Set the grey level value of a pixel specified by (x,y).

Throws an exception if coordinates are not valid.

Parameters:
x,y   The coordinates of the pixel
level   The brightness of the pixel

Definition at line 187 of file ImageGrey.cpp.

Referenced by Image::set_brightness().

bool ImageGrey::sobel ( ImageGrey & result )
 

Performs a sobel (horizontal and vertical) edge detection.

N.B. Result magnitudes may exceed 255. For visualisation use threshold() or /= 4.

Parameters:
result   ImageGrey object that result is to be stored in.

Definition at line 645 of file ImageGrey.cpp.

bool ImageGrey::sobel_horizontal ( ImageGrey & result )
 

Performs a horizontal sobel edge detection.

N.B. Result is normalised by dividing by 8

Parameters:
result   ImageGrey object that result is to be stored in.

Definition at line 525 of file ImageGrey.cpp.

bool ImageGrey::sobel_vertical ( ImageGrey & result )
 

Performs a vertical sobel edge detection.

N.B. Result is normalised by dividing by 8

Parameters:
result   ImageGrey object that result is to be stored in.

Definition at line 585 of file ImageGrey.cpp.

void ImageGrey::threshold ( int thresh )
 

Threshold brightness.

Parameters:
thresh   Threshold value

Definition at line 449 of file ImageGrey.cpp.

float ImageGrey::wavelet_convolve ( unsigned int x,
unsigned int y,
Wavelet * wavelet,
float * real,
float * imag )
 

Performs convolutions with real and imaginary wavelet kernels.

Returns the SQUARE of the magnitude (for reasons of computational efficiency). N.B. No check is made on the validity of the kernel centre w.r.t. kernel and image size.

Parameters:
x   X co-ordinate of kernal centre in image
y   Y co-ordinate of kernal centre in image
wavelet   ponter to Wavelet object
real   The real part of transform returned to 'real' is not NULL
imag   The imaginary part of transform returned to 'imag' is not NULL

Definition at line 150 of file ImageGrey-conv.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