libcvd
Public Member Functions | Public Attributes | Related Functions | List of all members
CVD::ImageRef Class Reference

#include <image_ref.h>

Public Member Functions

constexpr ImageRef ()
 Construct an ImageRef initialised at (0,0)
 
constexpr ImageRef (const ImageRef &)=default
 
constexpr ImageRef (int xp, int yp)
 Construct an ImageRef. More...
 
 ImageRef (std::istream &is)
 Construct an ImageRef from a stream. More...
 
bool next (const ImageRef &max)
 Step to the next co-ordinate in the image (in horizontal scanline order). More...
 
bool prev (const ImageRef &max)
 Step to the previous co-ordinate in the image (in horizontal scanline order). More...
 
bool next (const ImageRef &min, const ImageRef &max)
 Step to the next co-ordinate in the image (in horizontal scanline order), for pixels within a rectangular window Successive calls to this function will work backwards along each row of the image. More...
 
bool prev (const ImageRef &min, const ImageRef &max)
 Step to the previous co-ordinate in the image (in horizontal scanline order), for pixels within a rectangule window Successive calls to this function will work backwards along each row of the image. More...
 
void home ()
 Resets the ImageRef to (0,0)
 
void end (const ImageRef &size)
 Resets the ImageRef to the maximum co-ordinate in the image i.e. More...
 
constexpr ImageRefoperator= (const ImageRef &ref)
 Assigment. More...
 
constexpr bool operator== (const ImageRef &ref) const
 Logical equals. More...
 
constexpr bool operator!= (const ImageRef &ref) const
 Logical not equals. More...
 
constexpr ImageRef operator- () const
 Unary minus. Negates both x and y components.
 
constexpr ImageRefoperator*= (const double scale)
 Multiply both x and y co-ordinates by a scalar. More...
 
constexpr ImageRefoperator/= (const double scale)
 Divide both x and y co-ordinates by a scalar. More...
 
constexpr ImageRefoperator+= (const ImageRef rhs)
 Add an offset to the co-ordinate. More...
 
constexpr ImageRefoperator-= (const ImageRef rhs)
 Subtract an offset from the co-ordinate. More...
 
constexpr ImageRef operator* (const double scale) const
 Multiply both x and y co-ordinates by a scalar. More...
 
constexpr ImageRef operator/ (const double scale) const
 Divide both x and y co-ordinates by a scalar. More...
 
constexpr ImageRef operator+ (const ImageRef rhs) const
 Add an offset to the co-ordinate. More...
 
constexpr ImageRef operator- (const ImageRef rhs) const
 Subtract an offset from the co-ordinate. More...
 
constexpr ImageRefoperator<<= (int i)
 Bitwise left-shift operator. More...
 
constexpr ImageRefoperator>>= (int i)
 Bitwise right-shift operator. More...
 
constexpr ImageRef operator>> (int i) const
 Bitwise right-shift operator. More...
 
constexpr ImageRef operator<< (int i) const
 Bitwise left-shift operator. More...
 
constexpr bool operator< (const ImageRef &other) const
 An ImageRef is less than another ImageRef if it is earlier in the standard horizontal scan-line order, i.e. More...
 
constexpr bool operator> (const ImageRef &other) const
 An ImageRef is greater than another ImageRef if it is earlier in the standard horizontal scan-line order, i.e. More...
 
constexpr unsigned int mag_squared () const
 Magnitude-squared (x*x + y*y)
 
constexpr int area () const
 Area (product of x and y; signed)
 
constexpr ImageRef dot_times (const ImageRef &ref) const
 The equivalent of doing .* in matlab.
 
constexpr int & operator[] (int i)
 Square bracket subscripts for easy loops. 0=x 1=y other=error.
 
constexpr int operator[] (int i) const
 Square bracket const subscripts for easy loops. 0=x 1=y other=error.
 
constexpr ImageRef shiftl (int i) const
 
constexpr ImageRef shiftr (int i) const
 
constexpr ImageRef transpose () const
 

Public Attributes

int x
 The x co-ordinate.
 
int y
 The y co-ordinate.
 

Related Functions

(Note that these are not member functions.)

constexpr ImageRef operator* (const int scale, const ImageRef &ref)
 Left-multiply an ImageRef by a scalar. More...
 
std::ostream & operator<< (std::ostream &os, const ImageRef &ref)
 Write an ImageRef to a stream in the format "[x y]". More...
 
std::istream & operator>> (std::istream &is, ImageRef &ref)
 Read an ImageRef from a stream. More...
 
const ImageRef ImageRef_zero (0, 0)
 A zero ImageRef. More...
 

Detailed Description

An (x,y) image co-ordinate

Constructor & Destructor Documentation

◆ ImageRef() [1/2]

constexpr ImageRef::ImageRef ( int  xp,
int  yp 
)
inline

Construct an ImageRef.

Parameters
xpThe x co-ordinate
ypThe y co-ordinate

◆ ImageRef() [2/2]

ImageRef::ImageRef ( std::istream &  is)
inline

Construct an ImageRef from a stream.

Parameters
isThe stream to read

Member Function Documentation

◆ end()

void ImageRef::end ( const ImageRef size)
inline

Resets the ImageRef to the maximum co-ordinate in the image i.e.

(size.x - 1, size.y - 1)

Parameters
sizeThe size of the image

◆ next() [1/2]

bool ImageRef::next ( const ImageRef max)
inline

Step to the next co-ordinate in the image (in horizontal scanline order).

Successive calls to this function will work along each row of the image. If the next co-ordinate is off the end of the image, it returns false.

Parameters
maxThe size of the image

◆ next() [2/2]

bool ImageRef::next ( const ImageRef min,
const ImageRef max 
)
inline

Step to the next co-ordinate in the image (in horizontal scanline order), for pixels within a rectangular window Successive calls to this function will work backwards along each row of the image.

If the next co-ordinate is off the start of the image, it returns false.

Parameters
minThe minimum (x,y) co-ordinates in the window
maxThe minimum (x,y) co-ordinates in the window

◆ operator!=()

constexpr bool ImageRef::operator!= ( const ImageRef ref) const
inline

Logical not equals.

Parameters
refThe co-ordinate to compare with

◆ operator*()

constexpr ImageRef ImageRef::operator* ( const double  scale) const
inline

Multiply both x and y co-ordinates by a scalar.

Parameters
scaleThe multiplier

◆ operator*=()

constexpr ImageRef & ImageRef::operator*= ( const double  scale)
inline

Multiply both x and y co-ordinates by a scalar.

Parameters
scaleThe multiplier

◆ operator+()

constexpr ImageRef ImageRef::operator+ ( const ImageRef  rhs) const
inline

Add an offset to the co-ordinate.

Parameters
rhsThe offset

◆ operator+=()

constexpr ImageRef & ImageRef::operator+= ( const ImageRef  rhs)
inline

Add an offset to the co-ordinate.

Parameters
rhsThe offset

◆ operator-()

constexpr ImageRef ImageRef::operator- ( const ImageRef  rhs) const
inline

Subtract an offset from the co-ordinate.

Parameters
rhsThe offset

◆ operator-=()

constexpr ImageRef & ImageRef::operator-= ( const ImageRef  rhs)
inline

Subtract an offset from the co-ordinate.

Parameters
rhsThe offset

◆ operator/()

constexpr ImageRef ImageRef::operator/ ( const double  scale) const
inline

Divide both x and y co-ordinates by a scalar.

Parameters
scaleThe factor

◆ operator/=()

constexpr ImageRef & ImageRef::operator/= ( const double  scale)
inline

Divide both x and y co-ordinates by a scalar.

Parameters
scaleThe factor

◆ operator<()

constexpr bool ImageRef::operator< ( const ImageRef other) const
inline

An ImageRef is less than another ImageRef if it is earlier in the standard horizontal scan-line order, i.e.

has a smaller y-co-ordinate or the same y-co-ordinate but a smaller x-co-ordinate. An ordering of ImageRefs is needed to allow them to be used in STL for sets, maps, multisets, multimaps etc.

◆ operator<<()

constexpr ImageRef ImageRef::operator<< ( int  i) const
inline

Bitwise left-shift operator.

Parameters
iThe amount to shift

◆ operator<<=()

constexpr ImageRef & ImageRef::operator<<= ( int  i)
inline

Bitwise left-shift operator.

Parameters
iThe amount to shift

◆ operator=()

constexpr ImageRef & ImageRef::operator= ( const ImageRef ref)
inline

Assigment.

Parameters
refThe co-ordinate to copy

◆ operator==()

constexpr bool ImageRef::operator== ( const ImageRef ref) const
inline

Logical equals.

Parameters
refThe co-ordinate to compare with

◆ operator>()

constexpr bool ImageRef::operator> ( const ImageRef other) const
inline

An ImageRef is greater than another ImageRef if it is earlier in the standard horizontal scan-line order, i.e.

has a smaller y-co-ordinate or the same y-co-ordinate but a smaller x-co-ordinate.

◆ operator>>()

constexpr ImageRef ImageRef::operator>> ( int  i) const
inline

Bitwise right-shift operator.

Parameters
iThe amount to shift

◆ operator>>=()

constexpr ImageRef & ImageRef::operator>>= ( int  i)
inline

Bitwise right-shift operator.

Parameters
iThe amount to shift

◆ prev() [1/2]

bool ImageRef::prev ( const ImageRef max)
inline

Step to the previous co-ordinate in the image (in horizontal scanline order).

Successive calls to this function will work backwards along each row of the image. If the next co-ordinate is off the start of the image, it returns false.

Parameters
maxThe size of the image

◆ prev() [2/2]

bool ImageRef::prev ( const ImageRef min,
const ImageRef max 
)
inline

Step to the previous co-ordinate in the image (in horizontal scanline order), for pixels within a rectangule window Successive calls to this function will work backwards along each row of the image.

If the next co-ordinate is off the start of the image, it returns false.

Parameters
minThe minimum (x,y) co-ordinates in the window
maxThe minimum (x,y) co-ordinates in the window

◆ shiftl()

constexpr ImageRef ImageRef::shiftl ( int  i) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ shiftr()

constexpr ImageRef ImageRef::shiftr ( int  i) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Friends And Related Function Documentation

◆ ImageRef_zero()

const ImageRef ImageRef_zero ( ,
 
)
related

A zero ImageRef.

◆ operator*()

constexpr ImageRef operator* ( const int  scale,
const ImageRef ref 
)
related

Left-multiply an ImageRef by a scalar.

Mutiplies both x and y.

Parameters
scaleThe multiplier
refThe ImageRef to scale

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const ImageRef ref 
)
related

Write an ImageRef to a stream in the format "[x y]".

Parameters
osThe stream
refThe co-ordinate

◆ operator>>()

std::istream & operator>> ( std::istream &  is,
ImageRef ref 
)
related

Read an ImageRef from a stream.

Any format with two successive numbers will work


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