Pink 0.9
|
This class represents the image types used in Pink-C++ and Pink-Python. More...
Public Member Functions | |
ujoi () | |
ujoi (std::string filename, std::string debug="") | |
Reads an empty image from a file. | |
ujoi (xvimage *src, std::string debug="") | |
Embedding constructor. Takes 'xvimage' DOES NOT make a copy. It is embedded supposing that xvimage was created with malloc/free. | |
ujoi (const xvimage &src, std::string debug="") | |
Deep constructor. | |
ujoi (const ujoi< pixel_type > &src, std::string debug="") | |
SHALLOW! copy_constructor. | |
image_type | operator= (const image_type &other) |
SHALLOW! copy constructor. | |
void | reset (image_type &other) |
image_type | clone (void) const |
DEEP copy This method is used, if you need a runtime deep-copy of the object. The object creates a new object which is a deep copy of itself. | |
image_type | swap (image_type other) |
Content swap This method swaps the content of two images. The swap happens in constant time. The swap is achieved by exchanging the pointers guarding the content of the image. Used for iterations. | |
ujoi (const types::vint &dim, std::string debug="") | |
Creates an empty image of the given size. This constructor is mostly used from python, as it takes a python vector. | |
virtual | ~ujoi () |
ujoi (const types::vint &dim, boost::shared_array< pixel_type > data, std::string debug="") | |
ujoi (const types::vint &dim, pixel_type *data, std::string debug="") | |
pixel_type & | operator[] (index_t pos) |
Index access to the pixels With this operator you can access the pixels, as the image was a vector; regardless of its dimensions. | |
pixel_type & | operator() (index_t pos) |
Same as operator[]. Included to avoid ambiguity. | |
pixel_type & | operator[] (const types::vint &pos) |
'types::vint' access to the pixels With this operator you can access the pixels, by specifying the position of the pixel with a 'types::vint' vector. | |
const pixel_type & | get_operator_int (index_t pos) const |
Python vector access to the pixels. | |
xvimage * | get_output () |
Cast operator. Casts the ujoi<> object to 'xvimage*' in constant time. | |
operator xvimage * () | |
Cast operator. Casts the ujoi<> object to 'xvimage*' in constant time. | |
operator const xvimage * () const | |
Cast operator. Casts the ujoi<> object to 'xvimage*' in constant time. | |
const types::vint & | get_size () const |
Returns a vector with the size of the image object. | |
const types::vint & | get_center () const |
Returns a vector with the center of the image object. | |
void | set_center_vint (const types::vint &new_center) |
Sets the center of the image. | |
boost::shared_array< pixel_type > | get_pixels () |
Sets the center of the image. This method is called from Python. | |
void | set_pixels (long ptr, long nbytes) |
Takes a pointer in and copy the data it points to onto the image buffer. | |
std::string | repr () const |
Returns a string with some informations about the image. Generally it's size and pixel type. | |
image_type | fill (pixel_type value) |
Fills the image with the given value. That is sets every element of the image to the given value. | |
image_type | operator= (pixel_type value) |
Fills the image with the given value. That is sets every element of the image to the given value. Same as fill, but in operator form. | |
index_t | area () |
Counts the non zero pixels. | |
double | average () |
Counts the image average value. | |
bool | isnull () |
Tests if every pixel is null in the image. | |
double | volume () |
Calculates the volume of the image (the sum of every pixel). |
This class represents the image types used in Pink-C++ and Pink-Python.
pixel_type_ | can be 'char', 'short', 'int', 'float' and 'double' while int_pixel_type is the type's encoding into integer. See 'mccodimage.h' |
pink::ujoi< pixel_type >::ujoi | ( | ) |
Creates an empty image, used in uiSqhool for determining the image type.
pink::ujoi< pixel_type >::ujoi | ( | std::string | filename, |
std::string | debug = "" |
||
) |
Reads an empty image from a file.
filename | The image file |
debug | Holds an optional name for debug purposes. Never really catched on. |
References xvimage::col_size, xvimage::data_storage_type, xvimage::depth_size, freeimage(), pink::getDimensions(), xvimage::image_data, readimage(), xvimage::row_size, xvimage::time_size, and writeimage().
pink::ujoi< pixel_type >::ujoi | ( | xvimage * | src, |
std::string | debug = "" |
||
) |
Embedding constructor. Takes 'xvimage' DOES NOT make a copy. It is embedded supposing that xvimage was created with malloc/free.
src | Source object. |
debug | Holds an optional name for debug purposes. Never really catched on. |
References xvimage::col_size, xvimage::data_storage_type, xvimage::depth_size, pink::getDimensions(), xvimage::row_size, and xvimage::time_size.
pink::ujoi< pixel_type >::ujoi | ( | const xvimage & | src, |
std::string | debug = "" |
||
) |
Deep constructor.
Takes 'xvimage' and makes a copy.
debug | Holds an optional name for debug purposes. Never really catched on. |
References xvimage::col_size, xvimage::data_storage_type, xvimage::depth_size, pink::getDimensions(), xvimage::image_data, xvimage::row_size, and xvimage::time_size.
pink::ujoi< pixel_type_ >::ujoi | ( | const ujoi< pixel_type > & | src, |
std::string | debug = "" |
||
) |
SHALLOW! copy_constructor.
src | Source object |
debug | Holds an optional name for debug purposes. Never really catched on. |
pink::ujoi< pixel_type >::ujoi | ( | const types::vint & | dim, |
std::string | debug = "" |
||
) |
Creates an empty image of the given size. This constructor is mostly used from python, as it takes a python vector.
dim | The dimensions of the image |
debug | Creates an empty image of the given size. |
dim | The dimensions of the image |
debug |
pink::ujoi< pixel_type >::~ujoi | ( | ) | [virtual] |
The default destructor
pink::ujoi< pixel_type >::ujoi | ( | const types::vint & | dim, |
boost::shared_array< pixel_type > | data, | ||
std::string | debug = "" |
||
) |
Used to construct from ujif.
pink::ujoi< pixel_type >::ujoi | ( | const types::vint & | dim, |
pixel_type * | data, | ||
std::string | debug = "" |
||
) |
Creates a deep copy from a BLAS-style array. The pointer, and the dimensions are specified.
ujoi< pixel_type > pink::ujoi< pixel_type >::clone | ( | void | ) | const |
DEEP copy This method is used, if you need a runtime deep-copy of the object. The object creates a new object which is a deep copy of itself.
const pixel_type & pink::ujoi< pixel_type >::get_operator_int | ( | index_t | pos | ) | const |
Python vector access to the pixels.
This method let's you access the pixels using a Python vector. It is mainly used from python Example (in the Python interpreter):
I=pink.cpp.char_image([10,20,30]) print I[[0,3,2]]
pos | The vector with the position. |
boost::shared_array< pixel_type > pink::ujoi< pixel_type >::get_pixels | ( | ) |
Sets the center of the image. This method is called from Python.
The image center is mainly used in masks. For example the opening operator applies the image relative to it's center. Returns a smart pointer to the array of the pixels.
ujoi< im_type > pink::ujoi< im_type >::operator= | ( | const image_type & | other | ) |
SHALLOW! copy constructor.
This operator takes an object, and copies it's data pointers. If you create an object in a function it assures the return of the object without copying it's data.
Example:
char_image function( ... ) { types::vint size(3); size << 1000, 1000, 1000; char_image result(size); return result; }
Normally at the end of this function the compiler calls the copy constructor. Here, however as the data is held in smart pointers, only the pointers will be copied. For this reason the above example returns the 'result' in constant time.
other | The object to copy |
pixel_type & pink::ujoi< pixel_type >::operator[] | ( | index_t | pos | ) |
Index access to the pixels With this operator you can access the pixels, as the image was a vector; regardless of its dimensions.
pos | The number of the pixel in the linear array. |
Example:
types::vint size(3); size << 10,20,30; char_image I(size); std::cout << I[100]; I[200]=3;
pixel_type & pink::ujoi< pixel_type >::operator[] | ( | const types::vint & | pos | ) |
'types::vint' access to the pixels With this operator you can access the pixels, by specifying the position of the pixel with a 'types::vint' vector.
pos | A vector pointing somewhere in the image. |
Example:
types::vint size(3); size << 10,20,30; types::vint position(3); position << 3,4,2; char_image I(size); std::cout << I[position]; position << 4,4,4; I[position]=3;
void pink::ujoi< pixel_type >::reset | ( | image_type & | other | ) |
runtime shallow copy
void pink::ujoi< pixel_type >::set_center_vint | ( | const types::vint & | new_center | ) |
Sets the center of the image.
The image center is mainly used in masks. For example the opening operator applies the image relative to it's center.