46 namespace Exceptions {
59 what =
"Incompatible image sizes in " +
function;
68 what =
"Input ImageRefs not in image in " +
function;
81 #define CVD_IMAGE_ASSERT(X,Y)
101 template<
class T>
inline void memfill(T* data,
int n,
const T val)
104 for(;data < de; data++)
108 template<>
inline void memfill(
unsigned char* data,
int n,
const unsigned char val)
110 memset(data, val, n);
113 template<>
inline void memfill(
signed char* data,
int n,
const signed char val)
115 memset(data, val, n);
118 template<>
inline void memfill(
char* data,
int n,
const char val)
120 memset(data, val, n);
159 return s.
end != NULL;
168 return !((*this)!=s);
176 return s.
end != NULL;
197 :
ptr(const_cast<T*>(start)),
248 template<
class T>
class SubImage
273 return ir.
x >=border && ir.
y >=border && ir.
x <
my_size.
x - border && ir.
y <
my_size.
y - border;
321 int diff = ptr -
data();
358 inline const_iterator
end()
const
651 CopyPlaceHolder c = {
this};
739 Image(
const std::pair<ImageRef, T>& p)
787 if(this->
my_data && *num_copies && --(*num_copies) == 0)
798 if(copyof != NULL && copyof->
my_data != NULL)
#define CVD_IMAGE_ASSERT(X, Y)
SubImage & ref()
Return a reference to a SubImage. Useful for passing anonymous SubImages to functions.
Image(Internal::ImagePromise< C > p)
BasicImage(const BasicImage ©of)
T * end_ptr()
Return an off-the-end pointer without ever throwing AccessOutsideImage.
int totalsize() const
What is the total number of elements in the image (i.e. size().x * size().y), including padding...
SubImageIterator< T > iterator
BasicImage(T *data, const ImageRef &size)
T & operator[](const ImageRef &pos)
ConstSubImageIterator(const T *start, int image_width, int row_stride, const T *off_end)
const T & operator*() const
void resize(const ImageRef &size)
T * data()
Returns the raw image data.
Image(const ImageRef &size, const T &val)
SubImage(T *data, const ImageRef &size, int stride)
Image(const std::pair< ImageRef, T > &p)
ImageCreationIterator< C > CreateImagesEnd(const C &, int i)
iterator end()
Returns an iterator pointing to one past the end of the image.
~BasicImage()
The image data is not destroyed when a BasicImage is destroyed.
const SubImage sub_image(const ImageRef &start, const ImageRef &size) const
const T & operator[](const ImageRef &pos) const
void memfill(T *data, int n, const T val)
ImageCreationIterator(const T &data)
ConstSubImageIterator< T > const_iterator
bool operator!=(const ImageCreationIterator &i)
void copy(const BasicImage< S > &in, BasicImage< T > &out, ImageRef size=ImageRef(-1,-1), ImageRef begin=ImageRef(), ImageRef dst=ImageRef())
Image(const CopyPlaceHolder &c)
SubImageIterator(T *start, int image_width, int row_stride, const T *off_end)
int row_stride() const
What is the row stride of the image?
void copy_from(const BasicImage< T > ©)
void copy_from(const SubImage< T > ©)
const Image & operator=(const Image ©of)
IncompatibleImageSizes(const std::string &function)
ptrdiff_t difference_type
const T * operator[](int row) const
int my_stride
The row stride.
const T * end_ptr() const
Return an off-the-end pointer without ever throwing AccessOutsideImage.
SubImage sub_image(const ImageRef &start, const ImageRef &size)
BasicImage()
The default constructor does nothing.
const ConstSubImageIterator & operator++()
Image(const ImageRef &size)
void make_unique()
Make this image independent of any copies (i.e. force a copy of the image data).
~SubImage()
The image data is not destroyed when a BasicImage is destroyed.
ImageRef size() const
What is the size of this image?
bool in_image_with_border(const ImageRef &ir, int border) const
~Image()
The destructor removes the image data.
ImageRefNotInImage(const std::string &function)
void copy_from(const SubImage< T > &other)
iterator begin()
Returns an iterator referencing the first (top-left) pixel in the image.
const T * data() const
Returns the raw image data.
Image()
Default constructor.
ImageRef ir(const TooN::Vector< 2 > &v)
bool operator<(const ConstSubImageIterator &s) const
ImageCreationIterator(int i)
std::forward_iterator_tag iterator_category
void dup_from(const Image *copyof)
ImageRef my_size
The size of the image.
SubImage(const SubImage ©of)
const_iterator end() const
const T * construct_from_me
void operator=(const BasicImage ©of)
const_iterator begin() const
bool operator==(const ImageCreationIterator &i)
const Image & operator=(Internal::ImagePromise< C > p)
void home()
Resets the ImageRef to (0,0)
const T * operator->() const
const_iterator begin() const
Returns a const iterator referencing the first (top-left) pixel in the image.
void zero()
Set all the pixels in the image to zero. This is a relatively fast operation, using memset...
ImageCreationIterator< C > CreateImagesBegin(const C &from_me)
std::string what
The error message.
ConstSubImageIterator(const T *end)
ImageRef pos(const T *ptr) const
Given a pointer, this returns the image position as an ImageRef.
CopyPlaceHolder copy_from_me() const
T * my_data
The raw image data.
bool operator==(const ConstSubImageIterator &s) const
bool in_image(const ImageRef &ir) const
void resize(const ImageRef &size, const T &val)
bool operator!=(const ConstSubImageIterator &s) const
const_iterator end() const
Returns a const iterator pointing to one past the end of the image.