32 #ifndef __CVD_IMAGE_REF_H__
33 #define __CVD_IMAGE_REF_H__
161 inline int area()
const;
209 is.read((
char*)&
x,
sizeof(
int));
210 is.read((
char*)&
y,
sizeof(
int));
222 return(++
x < max.
x || (
x=0, ++
y < max.
y) || (
y=0,
false));
227 return (++
x < max.
x || (
x=min.
x, ++
y < max.
y) || (
y=min.
y,
false));
232 return(--
x > -1 || (
x=max.
x-1, --
y > -1) || (
y=max.
y-1,
false));
237 return (--
x > min.
x-1 || (
x=max.
x-1, --
y > min.
y-1) || (
y=max.
y-1,
false));
260 return (
x==ref.
x &&
y==ref.
y);
265 return (
x!=ref.
x ||
y!=ref.
y);
374 return y < other.
y || (
y == other.
y &&
x < other.
x);
379 return y > other.
y || (
y == other.
y &&
x > other.
x);
403 typedef unsigned int uint;
404 return uint(
x*
x) + uint(
y*
y);
426 return os <<
"[" << ref.
x <<
" " << ref.
y <<
"]";
437 unsigned char c = is.get();
444 is >> std::ws >> ref.
x >> std::ws;
449 is >> std::ws >> ref.
y >> std::ws;
456 is >> std::ws >> ref.
x >> std::ws >> ref.
y >> std::ws;
463 is >> ref.
x >> ref.
y;
471 is.setstate(std::ios_base::badbit);
ImageRef operator/(const double scale) const
std::ostream & operator<<(std::ostream &os, const ImageRef &ref)
ImageRef & operator+=(const ImageRef rhs)
bool operator<(const ImageRef &other) const
ImageRef & operator*=(const double scale)
ImageRef operator*(const double scale) const
ImageRef()
Construct an ImageRef initialised at (0,0)
int area() const
Area (product of x and y; signed)
ImageRef operator>>(int i) const
ImageRef & operator<<=(int i)
unsigned int mag_squared() const
Magnitude-squared (x*x + y*y)
bool prev(const ImageRef &max)
bool next(const ImageRef &max)
void end(const ImageRef &size)
ImageRef dot_times(const ImageRef &ref) const
The equivalent of doing .* in matlab.
ImageRef operator-() const
Unary minus. Negates both x and y components.
ImageRef & operator=(const ImageRef &ref)
ImageRef shiftr(int i) const
ImageRef operator+(const ImageRef rhs) const
bool operator==(const ImageRef &ref) const
ImageRef & operator-=(const ImageRef rhs)
ImageRef & operator>>=(int i)
void home()
Resets the ImageRef to (0,0)
ImageRef operator*(const int scale, const ImageRef &ref)
Exception if subscript for [] is not 0 or 1.
std::istream & operator>>(std::istream &is, ImageRef &ref)
ImageRef & operator/=(const double scale)
int & operator[](int i)
Square bracket subscripts for easy loops. 0=x 1=y other=error.
ImageRef operator<<(int i) const
bool operator>(const ImageRef &other) const
bool operator!=(const ImageRef &ref) const
ImageRef shiftl(int i) const