LArOpenCV  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Public Member Functions | Protected Attributes | Friends | List of all members
larcaffe::ImageMeta Class Reference

A simple class to store image's meta data including
0) origin (left-bottom corner of the picture) absolute coordinate
1) horizontal and vertical size (width and height) in double precision
2) number of horizontal and vertical pixels
It is meant to be associated with a specific cv::Mat or larcv::Image2D object
(where the latter class contains ImageMeta as an attribute). More...

#include <ImageMeta.h>

Public Member Functions

 ImageMeta (const double width=0., const double height=0., const size_t width_npixel=0., const size_t height_npixel=0, const double origin_x=0., const double origin_y=0.)
 Default constructor: width, height, and origin coordinate won't be modifiable. More...
 
 ~ImageMeta ()
 Default destructor. More...
 
const Point2Dorigin () const
 
double width () const
 
double height () const
 
size_t num_pixel_row () const
 
size_t num_pixel_column () const
 
double pixel_width () const
 
double pixel_height () const
 
double pixel_relative_x (size_t w) const
 Provide relative horizontal coordinate of the center of a specified pixel row. More...
 
double pixel_relative_y (size_t h) const
 Provide relative vertical coordinate of the center of a specified pixel column. More...
 
double pixel_x (size_t w) const
 Provide absolute horizontal coordinate of the center of a specified pixel row. More...
 
double pixel_y (size_t h) const
 Provide absolute vertical coordinate of the center of a specified pixel row. More...
 
void update (const size_t width_npixel, const size_t height_npixel)
 Change # of vertical/horizontal pixels in meta data. More...
 
void update (const ::cv::Mat &mat)
 Change # of vertical/horizontal pixels in meta data with cv::Mat as an input. More...
 

Protected Attributes

larcaffe::Point2D _origin
 Absolute coordinate of the left bottom corner of an image. More...
 
double _width
 Horizontal size of an image in double floating precision (in original coordinate unit size) More...
 
double _height
 Vertical size of an image in double floating precision (in original coordinate unit size) More...
 
size_t _width_npixel
 

of pixels in horizontal axis

More...
 
size_t _height_npixel
 

of pixels in vertical axis

More...
 

Friends

class Image2D
 

Detailed Description

A simple class to store image's meta data including
0) origin (left-bottom corner of the picture) absolute coordinate
1) horizontal and vertical size (width and height) in double precision
2) number of horizontal and vertical pixels
It is meant to be associated with a specific cv::Mat or larcv::Image2D object
(where the latter class contains ImageMeta as an attribute).

For cv::Mat, there
is a function ImageMeta::update to constantly update vertical/horizontal # pixels
as it may change in the course of matrix operation.

Definition at line 37 of file ImageMeta.h.

Constructor & Destructor Documentation

larcaffe::ImageMeta::ImageMeta ( const double  width = 0.,
const double  height = 0.,
const size_t  width_npixel = 0.,
const size_t  height_npixel = 0,
const double  origin_x = 0.,
const double  origin_y = 0. 
)
inline

Default constructor: width, height, and origin coordinate won't be modifiable.

Definition at line 44 of file ImageMeta.h.

References height(), update(), and width().

47  : _origin(origin_x,origin_y)
48  , _width(width)
49  , _height(height)
50  {
51  if( width < 0. ) throw larbys("Width must be a positive floating point!");
52  if( height < 0. ) throw larbys("Height must be a positive floating point!");
53  update(width_npixel,height_npixel);
54  }
larcaffe::ImageMeta::~ImageMeta ( )
inline

Default destructor.

Definition at line 57 of file ImageMeta.h.

57 {}

Member Function Documentation

double larcaffe::ImageMeta::height ( ) const
inline

Definition at line 61 of file ImageMeta.h.

References _height.

Referenced by ImageMeta().

61 { return _height; }
size_t larcaffe::ImageMeta::num_pixel_column ( ) const
inline

Definition at line 63 of file ImageMeta.h.

References _height_npixel.

63 { return _height_npixel; }
size_t larcaffe::ImageMeta::num_pixel_row ( ) const
inline

Definition at line 62 of file ImageMeta.h.

References _width_npixel.

62 { return _width_npixel; }
const Point2D& larcaffe::ImageMeta::origin ( ) const
inline

Definition at line 59 of file ImageMeta.h.

References _origin.

59 { return _origin; }
double larcaffe::ImageMeta::pixel_height ( ) const
inline

Definition at line 65 of file ImageMeta.h.

References _height, and _height_npixel.

Referenced by pixel_relative_y().

65 { return (_height_npixel ? _height / _height_npixel : 0.); }
double larcaffe::ImageMeta::pixel_relative_x ( size_t  w) const
inline

Provide relative horizontal coordinate of the center of a specified pixel row.

Definition at line 67 of file ImageMeta.h.

References pixel_width().

Referenced by pixel_x().

67 { return pixel_width () * ((double)w + 0.5); }
double larcaffe::ImageMeta::pixel_relative_y ( size_t  h) const
inline

Provide relative vertical coordinate of the center of a specified pixel column.

Definition at line 69 of file ImageMeta.h.

References pixel_height().

Referenced by pixel_y().

69 { return pixel_height () * ((double)h + 0.5); }
double larcaffe::ImageMeta::pixel_width ( ) const
inline

Definition at line 64 of file ImageMeta.h.

References _width, and _width_npixel.

Referenced by pixel_relative_x().

64 { return (_width_npixel ? _width / _width_npixel : 0.); }
double larcaffe::ImageMeta::pixel_x ( size_t  w) const
inline

Provide absolute horizontal coordinate of the center of a specified pixel row.

Definition at line 71 of file ImageMeta.h.

References _origin, pixel_relative_x(), and larcaffe::Point2D::x.

71 { return _origin.x + pixel_relative_x(w); }
double larcaffe::ImageMeta::pixel_y ( size_t  h) const
inline

Provide absolute vertical coordinate of the center of a specified pixel row.

Definition at line 73 of file ImageMeta.h.

References _origin, pixel_relative_y(), and larcaffe::Point2D::y.

73 { return _origin.y + pixel_relative_y(h); }
void larcaffe::ImageMeta::update ( const size_t  width_npixel,
const size_t  height_npixel 
)
inline

Change # of vertical/horizontal pixels in meta data.

Definition at line 75 of file ImageMeta.h.

References _height_npixel, and _width_npixel.

Referenced by larcaffe::Image2D::clear(), larcaffe::Image2D::copy_compress(), ImageMeta(), larcaffe::Image2D::resize(), and update().

76  {
77  //if( !width_npixel ) throw larbys("Number of pixels must be non-zero (width)");
78  //if( !height_npixel ) throw larbys("Number of pixels must be non-zero (height)");
79  _width_npixel = width_npixel;
80  _height_npixel = height_npixel;
81  }
void larcaffe::ImageMeta::update ( const ::cv::Mat &  mat)
inline

Change # of vertical/horizontal pixels in meta data with cv::Mat as an input.

Definition at line 83 of file ImageMeta.h.

References update().

84  { update(mat.rows,mat.cols); }
double larcaffe::ImageMeta::width ( ) const
inline

Definition at line 60 of file ImageMeta.h.

References _width.

Referenced by ImageMeta().

60 { return _width; }

Friends And Related Function Documentation

friend class Image2D
friend

Definition at line 39 of file ImageMeta.h.

Member Data Documentation

double larcaffe::ImageMeta::_height
protected

Vertical size of an image in double floating precision (in original coordinate unit size)

Definition at line 90 of file ImageMeta.h.

Referenced by height(), and pixel_height().

size_t larcaffe::ImageMeta::_height_npixel
protected
larcaffe::Point2D larcaffe::ImageMeta::_origin
protected

Absolute coordinate of the left bottom corner of an image.

Definition at line 88 of file ImageMeta.h.

Referenced by origin(), pixel_x(), and pixel_y().

double larcaffe::ImageMeta::_width
protected

Horizontal size of an image in double floating precision (in original coordinate unit size)

Definition at line 89 of file ImageMeta.h.

Referenced by pixel_width(), and width().

size_t larcaffe::ImageMeta::_width_npixel
protected

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