cpe::image Class Reference

Container for picture data. Data are stored as unsigned char [0,255]. More...

+ Collaboration diagram for cpe::image:

List of all members.

Public Member Functions

 image ()
 empty constructor
 image (const unsigned int &N)
 create square picture of size NxN
 image (const unsigned int &Nx, const unsigned int &Ny)
 create picture of size Nx x Ny
 image (const std::string &filename)
 import pre-existing picture from file filename
const unsigned int & get_Nx () const
 get the picture width in pixel
const unsigned int & get_Ny () const
 get the picture height in pixel
void resize (const unsigned int &N)
 resize the picture to a square of size NxN
void resize (const unsigned int &Nx, const unsigned int &Ny)
 resize the picture to a square of size Nx x Ny
void reshape (const unsigned int &Nx2)
 try to reshape the picture to a new size
bool check_position (const p2d &u) const
 check if a given pixel (kx,ky) is within the size of the picture
const coloroperator() (const p2d &index) const
 Accessor on a pixel.
coloroperator() (const p2d &index)
 Accessor on a pixel.
void set (const p2d &index, const color &c)
 Method to set a pixel.
void fill (const color &c)
 fill the entire picture with a given (r,g,b) color
void fill_rectangle (const p2d &u1, const p2d &u2, const color &c)
 fill a rectangle ((x1,y1);(x2,y2)) with a given (r,g,b) color
void export_file (const std::string &filename)
 write the picture into a file

Protected Member Functions

int coordinate_to_index (const p2d &u) const
 transform coordinate u=(kx,ky) to index in vector data

Private Attributes

std::vector< colorinternal_data
 internal data storage as std::vector of unsigned char
unsigned int internal_Nx
 storage of picture width
unsigned int internal_Ny
 storage of picture height

Detailed Description

Container for picture data. Data are stored as unsigned char [0,255].


Constructor & Destructor Documentation

empty constructor

Referenced by resize().

cpe::image::image ( const unsigned int &  N)

create square picture of size NxN

Parameters:
unsignedint N: size (width & height) of the picture

References internal_data.

cpe::image::image ( const unsigned int &  Nx,
const unsigned int &  Ny 
)

create picture of size Nx x Ny

Parameters:
unsignedint Nx: picture width
unsignedint Ny: picture height

References internal_data.

cpe::image::image ( const std::string &  filename)

import pre-existing picture from file filename

Parameters:
std::stringfilename: path to the file to load

References cpe::image_io::read_ppm().

+ Here is the call graph for this function:


Member Function Documentation

bool cpe::image::check_position ( const p2d u) const

check if a given pixel (kx,ky) is within the size of the picture

Parameters:
p2du: current (kx,ky)-coordinate
Returns:
true if (kx,ky) is within the picture, false otherwise

References internal_Nx, internal_Ny, cpe::p2d::x(), and cpe::p2d::y().

Referenced by fill_rectangle(), operator()(), and set().

+ Here is the call graph for this function:

int cpe::image::coordinate_to_index ( const p2d u) const [protected]

transform coordinate u=(kx,ky) to index in vector data

References internal_Nx, cpe::p2d::x(), and cpe::p2d::y().

Referenced by operator()(), and set().

+ Here is the call graph for this function:

void cpe::image::export_file ( const std::string &  filename)

write the picture into a file

References cpe::image_io::export_ppm().

Referenced by main().

+ Here is the call graph for this function:

void cpe::image::fill ( const color c)

fill the entire picture with a given (r,g,b) color

Parameters:
colorc: (red,green,blue) value

References internal_data.

void cpe::image::fill_rectangle ( const p2d u1,
const p2d u2,
const color c 
)

fill a rectangle ((x1,y1);(x2,y2)) with a given (r,g,b) color

Parameters:
p2du1: (x,y)-coordinate of starting point
p2du2: (x,y)-coordinate of ending point
colorc: (r,g,b) value

References check_position(), internal_Nx, internal_Ny, cpe::p2d::x(), and cpe::p2d::y().

+ Here is the call graph for this function:

const unsigned int & cpe::image::get_Nx ( ) const

get the picture width in pixel

References internal_Nx.

Referenced by cpe::image_io::export_ppm(), and cpe::ray_tracer::trace().

const unsigned int & cpe::image::get_Ny ( ) const

get the picture height in pixel

References internal_Ny.

Referenced by cpe::image_io::export_ppm(), and cpe::ray_tracer::trace().

const color & cpe::image::operator() ( const p2d index) const

Accessor on a pixel.

References check_position(), coordinate_to_index(), and internal_data.

+ Here is the call graph for this function:

color & cpe::image::operator() ( const p2d index)

Accessor on a pixel.

References check_position(), coordinate_to_index(), and internal_data.

+ Here is the call graph for this function:

void cpe::image::reshape ( const unsigned int &  Nx2)

try to reshape the picture to a new size

Parameters:
unsignedint Nx: the new picture width
Note:
Nx x Ny / Nx2 must be integer

References internal_Nx, and internal_Ny.

void cpe::image::resize ( const unsigned int &  N)

resize the picture to a square of size NxN

Parameters:
unsignedint N: new picture width and height

References image().

+ Here is the call graph for this function:

void cpe::image::resize ( const unsigned int &  Nx,
const unsigned int &  Ny 
)

resize the picture to a square of size Nx x Ny

Parameters:
unsignedint Nx: new picture width
unsignedNy: new picture height

References image().

+ Here is the call graph for this function:

void cpe::image::set ( const p2d index,
const color c 
)

Method to set a pixel.

References check_position(), coordinate_to_index(), and internal_data.

Referenced by cpe::ray_tracer::trace().

+ Here is the call graph for this function:


Member Data Documentation

std::vector<color> cpe::image::internal_data [private]

internal data storage as std::vector of unsigned char

Picture is stored as (color_0 , color_1 , ...) vector size is therefore 3 Nx Ny

Referenced by fill(), image(), operator()(), and set().

unsigned int cpe::image::internal_Nx [private]

storage of picture width

Referenced by check_position(), coordinate_to_index(), fill_rectangle(), get_Nx(), and reshape().

unsigned int cpe::image::internal_Ny [private]

storage of picture height

Referenced by check_position(), fill_rectangle(), get_Ny(), and reshape().


The documentation for this class was generated from the following files: