Pink 0.9
Public Member Functions

pink::ujoi< pixel_type_ > Class Template Reference

This class represents the image types used in Pink-C++ and Pink-Python. More...

Inheritance diagram for pink::ujoi< pixel_type_ >:
pink::pink_image

List of all members.

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.
xvimageget_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).

Detailed Description

template<class pixel_type_>
class pink::ujoi< pixel_type_ >

This class represents the image types used in Pink-C++ and Pink-Python.

Template Parameters:
pixel_type_can be 'char', 'short', 'int', 'float' and 'double' while int_pixel_type is the type's encoding into integer. See 'mccodimage.h'

Constructor & Destructor Documentation

template<class pixel_type >
pink::ujoi< pixel_type >::ujoi ( )

Creates an empty image, used in uiSqhool for determining the image type.

template<class pixel_type >
pink::ujoi< pixel_type >::ujoi ( std::string  filename,
std::string  debug = "" 
)

Reads an empty image from a file.

Note:
You have to know the image type prior to reading.
Parameters:
filenameThe image file
debugHolds 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().

template<class pixel_type >
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.

Parameters:
srcSource object.
debugHolds 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.

template<class pixel_type >
pink::ujoi< pixel_type >::ujoi ( const xvimage src,
std::string  debug = "" 
)

Deep constructor.

Takes 'xvimage' and makes a copy.

Parameters:
debugHolds 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.

template<class pixel_type_>
pink::ujoi< pixel_type_ >::ujoi ( const ujoi< pixel_type > &  src,
std::string  debug = "" 
)

SHALLOW! copy_constructor.

Note:
For conversion use convert2float
Parameters:
srcSource object
debugHolds an optional name for debug purposes. Never really catched on.
template<class pixel_type >
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.

Parameters:
dimThe dimensions of the image
debugCreates an empty image of the given size.
dimThe dimensions of the image
debug
template<class pixel_type >
pink::ujoi< pixel_type >::~ujoi ( ) [virtual]

The default destructor

template<class pixel_type >
pink::ujoi< pixel_type >::ujoi ( const types::vint &  dim,
boost::shared_array< pixel_type >  data,
std::string  debug = "" 
)

Used to construct from ujif.

template<class pixel_type >
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.


Member Function Documentation

template<class pixel_type >
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.

Returns:
The cloned image
template<class pixel_type >
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]]
Parameters:
posThe vector with the position.
Note:
The position is always checked, so the vector must point somewhere in the image.
Returns:
A reference to the pixel
template<class pixel_type >
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.

template<class im_type >
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.

Parameters:
otherThe object to copy
Returns:
It supports multiple attribution
template<class pixel_type >
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.

Parameters:
posThe number of the pixel in the linear array.
Returns:
Reference to the pixel.

Example:

    types::vint size(3);
    size << 10,20,30;
    char_image I(size);
    std::cout << I[100];
    I[200]=3;
template<class pixel_type >
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.

Parameters:
posA vector pointing somewhere in the image.
Returns:
Reference to the pixel.
Note:
The method tests if the vector is inside the image in DEBUG mode. In RELEASE mode, for performance reasons it accepts anything. If the code fail in the line where you access the image elements, you should consider recompiling in debug mode.

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;
template<class pixel_type >
void pink::ujoi< pixel_type >::reset ( image_type other)

runtime shallow copy

template<class pixel_type >
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.


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