cgv
Loading...
Searching...
No Matches
cgv::media::image::image Class Reference
Inheritance diagram for cgv::media::image::image:
cgv::data::data_format cgv::data::component_format cgv::data::packing_info

Public Member Functions

 image (const image &I)
 
template<typename T >
T * get_ptr ()
 
template<typename T >
const T * get_ptr () const
 
bool read (const std::string &file_name)
 
bool write (const std::string &file_name)
 
void hflip ()
 
void combine (const cgv::type::uint8_type *src_ptr, unsigned n_x, unsigned entry_size, unsigned n_y, unsigned row_size, cgv::type::uint8_type *dst_ptr)
 combine a rectangular image region into a single pixel
 
void copy (const image &I)
 constructs a copy of given image
 
void downscale (unsigned int size_x, unsigned int size_y, const image &I)
 construct a resized smaller version of given image using area averaging
 
void downsample (unsigned fx, unsigned fy, const image &I)
 downsample image in x and y direction by given downsampling factors fx and fy
 
void upscale (unsigned int size_x, unsigned int size_y, const image &I)
 construct a resized larger version of given image using bilinear interpolation
 
void resize (unsigned size_x, unsigned size_y, const image &I)
 construct a resized version of given image using the down- and upscale methods
 
- Public Member Functions inherited from cgv::data::data_format
 data_format ()
 construct an undefined data format
 
 data_format (const std::string &description)
 construct from description string, see set_data_format for docu
 
bool set_data_format (const std::string &description)
 Set data format from description string, which adds information to the description string of the component format and has the following syntax.
 
 data_format (size_t _width, cgv::type::info::TypeId _component_type, const std::string &_component_name_list, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct a 1d data format from width and the information needed to construct a component info
 
 data_format (size_t _width, cgv::type::info::TypeId _component_type, ComponentFormat _cf, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct a 1d data format from width and the information needed to construct a component info
 
 data_format (size_t _width, size_t _height, cgv::type::info::TypeId _component_type, const std::string &_component_name_list, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct a 2d data format from width and height
 
 data_format (size_t _width, size_t _height, cgv::type::info::TypeId _component_type, ComponentFormat _cf, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct a 2d data format from width and height
 
 data_format (size_t _width, size_t _height, size_t _depth, cgv::type::info::TypeId _component_type, const std::string &_component_name_list, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct a 3d data format from width, height and depth
 
 data_format (size_t _width, size_t _height, size_t _depth, cgv::type::info::TypeId _component_type, ComponentFormat _cf, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct a 3d data format from width, height and depth
 
 data_format (size_t _width, size_t _height, size_t _depth, size_t _count, cgv::type::info::TypeId _component_type, const std::string &_component_name_list, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct a 4d data format from width, height, depth and count
 
 data_format (size_t _width, size_t _height, size_t _depth, size_t _count, cgv::type::info::TypeId _component_type, ComponentFormat _cf, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct a 4d data format from width, height, depth and count
 
void set_dimensions (size_t _d0, size_t _d1=-1, size_t _d2=-1, size_t _d3=-1)
 set the dimensions to the given values
 
unsigned get_nr_dimensions () const
 return the number of dimensions of the data set
 
void set_nr_dimensions (unsigned _d)
 set the number of dimensions of the data set
 
size_t get_resolution (unsigned i) const
 return the resolution in the i-th dimension, or 0 if not defined
 
size_t get_width () const
 return the resolution in the first dimension, or 1 if not defined
 
size_t get_height () const
 return the resolution in the second dimension, or 1 if not defined
 
size_t get_depth () const
 return the resolution in the third dimension, or 1 if not defined
 
size_t get_nr_time_steps () const
 return the resolution in the highest dimension, or 1 if not defined
 
size_t get_nr_entries () const
 return the total number of data entries
 
size_t get_nr_bytes () const
 return the total number of bytes necessary to store the data
 
void set_resolution (unsigned i, size_t resolution)
 set the resolution in the i-th dimension, add dimensions if necessary
 
void set_width (size_t _width)
 set the resolution in the first dimension, add dimensions if necessary
 
void set_height (size_t _height)
 set the resolution in the second dimension, add dimensions if necessary
 
void set_depth (size_t _depth)
 set the resolution in the third dimension, add dimensions if necessary
 
void set_nr_time_steps (size_t _nr_time_steps)
 set the resolution in the last dimension, add dimensions if necessary
 
unsigned get_entry_alignment () const
 return the alignment of entries
 
unsigned get_alignment (unsigned i) const
 return the alignment of a given dimension, where the alignment of the last dimension is always 1 and cannot be changed.
 
void set_entry_alignment (unsigned _a)
 set the alignment of entries
 
void set_alignment (unsigned i, unsigned _a)
 set the alignment of a given dimension, add dimensions if necessary.
 
unsigned get_layout_dimension (unsigned dim) const
 return the layout dimension of a given dimension
 
void set_layout_dimension (unsigned dim, unsigned layout_dim)
 set the layout dimension of a given dimension, add dimensions if necessary
 
const component_formatget_component_format () const
 return the component_format info by simple conversion of the this pointer
 
void set_component_format (const component_format &cf)
 set component_format by simply assigning to a converted this pointer
 
bool operator== (const data_format &df) const
 comparison between component formats
 
bool operator!= (const data_format &df) const
 comparison between component formats
 
- Public Member Functions inherited from cgv::data::component_format
 component_format (const std::string &description)
 construct from description string, see set_component_format for docu
 
bool set_component_format (const std::string &description)
 set component format from description string, which has the following syntax.
 
void set_components (const std::string &_components)
 comma separated list of component descriptors, for example "R,G,B"
 
 component_format (cgv::type::info::TypeId _component_type=cgv::type::info::TypeId::TI_UNDEF, const std::string &_component_name_list="", unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct component format from component type, comma or colon separated list of component names, component alignment and bit depths for packed formats
 
 component_format (cgv::type::info::TypeId _component_type, ComponentFormat cf, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct component format from component type, standard component format, component alignment and bit depths for packed formats
 
void set_integer_interpretation (ComponentIntegerInterpretation cii)
 set the integer interpretation
 
ComponentIntegerInterpretation get_integer_interpretation () const
 return current integer interpretation
 
template<typename T >
get (int ci, const void *ptr) const
 constant access to the i-th component stored at the given location
 
template<typename T >
bool set (int ci, void *ptr, const T &v) const
 write access to the i-th component, return whether write was successful
 
bool empty () const
 return whether the component format is defined
 
void clear ()
 clear the component format
 
const packing_infoget_packing_info () const
 return the packing info by simple conversion of the this pointer
 
void set_packing_info (const packing_info &pi)
 set packing info by simply assigning to a converted this pointer
 
unsigned int get_nr_components () const
 return the number of components
 
unsigned int get_component_index (const std::string &name) const
 return the index of a component given by name or -1 if not found
 
std::string get_component_name (unsigned int i) const
 return the name of the component with index i
 
ComponentFormat get_standard_component_format () const
 return whether the component format is one of the standard formats
 
void set_component_names (const std::string &_component_name_list)
 set component names from a comma or colon separated list of names
 
void set_component_format (ComponentFormat _cf)
 set the component names from a standard component format
 
cgv::type::info::TypeId get_component_type () const
 return the component type
 
void set_component_type (cgv::type::info::TypeId _type_id)
 set the component type
 
unsigned int get_entry_size () const
 return the size of one entry of components in bytes
 
bool operator== (const component_format &cf) const
 comparison between component formats
 
bool operator!= (const component_format &cf) const
 comparison between component formats
 
- Public Member Functions inherited from cgv::data::packing_info
 packing_info (unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct packing information from alignment and bit depths.
 
void clear ()
 clear packing info information
 
unsigned get_bit_depth (unsigned ci) const
 return the bit depth of the ci-th component
 
void set_bit_depth (unsigned ci, unsigned depth)
 set the bit depth of the ci-th component
 
bool is_packing () const
 return whether packing is enabled
 
void set_packing (bool enable=true)
 set the packing flag
 
unsigned int get_component_alignment () const
 return the component alignment in bits in the packed case and in bytes in the unpacked case
 
void set_component_alignment (unsigned a)
 set the component alignment in bits in the packed case and in bytes in the unpacked case
 
int get_signed (unsigned ci, const void *ptr) const
 return the ci-th component of the data entry pointed to by the given pointer of a signed packed component
 
unsigned int get_unsigned (unsigned ci, const void *ptr) const
 return the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component
 
bool set_signed (unsigned ci, void *ptr, int v) const
 set the ci-th component of the data entry pointed to by the given pointer of a signed packed component
 
bool set_unsigned (unsigned ci, void *ptr, unsigned v) const
 set the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component
 
bool operator== (const packing_info &pi) const
 equal comparison
 
bool operator!= (const packing_info &pi) const
 unequal comparison
 

Protected Attributes

cgv::data::data_view dv
 
- Protected Attributes inherited from cgv::data::data_format
std::vector< dimension_infodimensions
 store for each dimension resolution and alignment in a dimension_info struct
 
- Protected Attributes inherited from cgv::data::component_format
cgv::type::info::TypeId component_type
 store the type id of the component type
 
ComponentIntegerInterpretation component_interpretation
 interpretation of integer typed components
 
std::string component_string
 store all component names in one string separated with 0-chars
 
std::vector< unsigned short > component_positions
 store the position of each component in the component string
 
- Protected Attributes inherited from cgv::data::packing_info
bool is_packed: 1
 
unsigned bd0: 6
 
unsigned bd1: 6
 
unsigned bd2: 6
 
unsigned bd3: 6
 
unsigned ca: 6
 

Additional Inherited Members

- Static Public Member Functions inherited from cgv::data::component_format
static const std::string & get_last_error ()
 returns an error string after parsing of description string has failed
 
- Static Public Member Functions inherited from cgv::data::packing_info
static size_t align (size_t v, unsigned a)
 return the next integer larger or equal to v which is dividable by a
 
- Protected Member Functions inherited from cgv::data::component_format
void extract_components ()
 extract components from component string
 
- Protected Member Functions inherited from cgv::data::packing_info
bool prepare_bit_operation (unsigned ci, void *ptr, unsigned &off, unsigned &bd, unsigned *&iptr) const
 
bool prepare_bit_operation (unsigned ci, const void *ptr, unsigned &off, unsigned &bd, const unsigned *&iptr) const
 
unsigned int get_bit_offset (unsigned ci) const
 
- Static Protected Attributes inherited from cgv::data::component_format
static std::string last_error
 store the last error that appeared during parsing of a description
 

Detailed Description

Definition at line 14 of file image.h.

Constructor & Destructor Documentation

◆ image() [1/2]

cgv::media::image::image::image ( )
inline

Definition at line 19 of file image.h.

◆ image() [2/2]

cgv::media::image::image::image ( const image I)
inline

Definition at line 20 of file image.h.

Member Function Documentation

◆ combine()

void cgv::media::image::image::combine ( const cgv::type::uint8_type src_ptr,
unsigned  n_x,
unsigned  entry_size,
unsigned  n_y,
unsigned  row_size,
cgv::type::uint8_type dst_ptr 
)
inline

combine a rectangular image region into a single pixel

Definition at line 53 of file image.h.

References cgv::data::component_format::get_nr_components().

◆ copy()

void cgv::media::image::image::copy ( const image I)
inline

constructs a copy of given image

Definition at line 68 of file image.h.

References cgv::data::component_format::get_entry_size(), cgv::data::data_format::set_height(), and cgv::data::data_format::set_width().

Referenced by resize().

◆ downsample()

void cgv::media::image::image::downsample ( unsigned  fx,
unsigned  fy,
const image I 
)
inline

downsample image in x and y direction by given downsampling factors fx and fy

Definition at line 155 of file image.h.

References downscale().

◆ downscale()

void cgv::media::image::image::downscale ( unsigned int  size_x,
unsigned int  size_y,
const image I 
)
inline

construct a resized smaller version of given image using area averaging

Definition at line 90 of file image.h.

References cgv::data::component_format::get_entry_size(), cgv::data::component_format::get_nr_components(), cgv::data::data_format::set_height(), and cgv::data::data_format::set_width().

Referenced by downsample(), and resize().

◆ get_ptr() [1/2]

template<typename T >
T * cgv::media::image::image::get_ptr ( )
inline

Definition at line 24 of file image.h.

◆ get_ptr() [2/2]

template<typename T >
const T * cgv::media::image::image::get_ptr ( ) const
inline

Definition at line 25 of file image.h.

◆ hflip()

void cgv::media::image::image::hflip ( )
inline

Definition at line 43 of file image.h.

◆ read()

bool cgv::media::image::image::read ( const std::string &  file_name)
inline

Definition at line 26 of file image.h.

◆ resize()

void cgv::media::image::image::resize ( unsigned  size_x,
unsigned  size_y,
const image I 
)
inline

construct a resized version of given image using the down- and upscale methods

Definition at line 228 of file image.h.

References copy(), downscale(), and upscale().

◆ upscale()

void cgv::media::image::image::upscale ( unsigned int  size_x,
unsigned int  size_y,
const image I 
)
inline

construct a resized larger version of given image using bilinear interpolation

Definition at line 160 of file image.h.

References cgv::data::component_format::get_entry_size(), cgv::data::component_format::get_nr_components(), cgv::data::data_format::set_height(), and cgv::data::data_format::set_width().

Referenced by resize().

◆ write()

bool cgv::media::image::image::write ( const std::string &  file_name)
inline

Definition at line 36 of file image.h.

Member Data Documentation

◆ dv

cgv::data::data_view cgv::media::image::image::dv
protected

Definition at line 17 of file image.h.


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