7 #include <cvd/convert_image.h> 8 #include <cvd/exceptions.h> 10 #include <cvd/image_ref.h> 11 #include <cvd/internal/builtin_components.h> 12 #include <cvd/internal/rgb_components.h> 13 #include <cvd/utility.h> 16 #include <cvd/config.h> 18 #include <TooN/TooN.h> 35 using CVD::Exceptions::All::All;
43 :
All(
"Input ImageRefs not in image in " +
function) {};
51 :
All(
"Incompatible image sizes in " +
function) {};
58 template <class T, unsigned int N = Pixel::Component<T>::count>
69 typedef typename Pixel::Component<T>::type TComp;
78 inline static const T&
gray()
100 typedef typename Pixel::Component<T>::type TComp;
101 static const TComp hi;
102 inline static T make(
const TComp& a,
const TComp& b,
const TComp& c)
110 inline static const T& black()
112 static const T c = make(0, 0, 0);
115 inline static const T& white()
117 static const T c = make(hi, hi, hi);
120 inline static const T& red()
122 static const T c = make(hi, 0, 0);
125 inline static const T& green()
127 static const T c = make(0, hi, 0);
130 inline static const T& blue()
132 static const T c = make(0, 0, hi);
135 inline static const T& cyan()
137 static const T c = make(0, hi, hi);
140 inline static const T& magenta()
142 static const T c = make(hi, 0, hi);
145 inline static const T& yellow()
147 static const T c = make(hi, hi, 0);
150 inline const T& shade(
const T& c,
double b)
173 double len = std::abs(dx) + std::abs(dy);
174 for(
int t = 0; t <= len; t++)
176 int x = (int)(x1 + t / (len)*dx + 0.5);
177 int y = (int)(y1 + t / (len)*dy + 0.5);
178 if(x >= 0 && x < w && y >= 0 && y < h)
192 drawLine(im,
double(p1.
x),
double(p1.
y),
double(p2.
x),
double(p2.
y), c);
205 drawLine(im, p1[0], p1[1], p2[0], p2[1], c);
219 for(
unsigned int i = 0; i < points.size() - 1; i++)
220 drawLine(im, points[i] + offset, points[i + 1] + offset, c);
221 drawLine(im, points.back() + offset, points.front() + offset, c);
232 template <
class T,
class Po
intIterator>
234 PointIterator begin, PointIterator end,
const T& c)
240 PointIterator last(begin);
241 PointIterator it(begin);
243 for(; it != end; it++)
245 drawLine(im, *last + offset, *(it) + offset, c);
248 drawLine(im, (*last) + offset, (*begin) + offset, c);
260 drawLine(im, upperleft.
x, upperleft.
y, upperleft.
x, lowerright.
y, c);
261 drawLine(im, upperleft.
x, upperleft.
y, lowerright.
x, upperleft.
y, c);
262 drawLine(im, upperleft.
x, lowerright.
y, lowerright.
x, lowerright.
y, c);
263 drawLine(im, lowerright.
x, upperleft.
y, lowerright.
x, lowerright.
y, c);
284 std::vector<ImageRef>
getCircle(
int radius);
291 std::vector<ImageRef>
getDisc(
double radius);
293 #if defined CVD_HAVE_TOON || defined DOXYGEN_IGNORE_INTERNAL 294 std::vector<ImageRef> getSolidEllipse(
float r1,
float r2,
float theta);
309 template <
class S,
class T,
class U>
312 int h = std::max(a.
size().y, b.
size().y);
327 for(
int i = blackBegin.
y; i < blackEnd.
y; i++)
328 for(
int j = blackBegin.
x; j < blackEnd.
x; j++)
338 template <
class S,
class T,
class U>
346 if(size == ImageRef_zero)
349 if(size.x + dst.x >= a.
size().x)
350 size.x = a.
size().x - dst.x;
351 if(size.x + dst.x >= out.
size().x)
352 size.x = out.
size().x - dst.x;
353 if(size.y + dst.y >= a.
size().y)
354 size.y = a.
size().y - dst.y;
355 if(size.y + dst.y >= out.
size().y)
356 size.y = out.
size().y - dst.y;
368 out[sourceA] += b[sourceB];
369 while(sourceA.next(dst, endA))
371 sourceB.
next(from, endB);
372 out[sourceA] += b[sourceB];
377 #endif // CVD_DRAW_H_ All classes and functions are within the CVD namespace.
Definition: argb.h:6
ImageRef size() const
What is the size of this image?
Definition: image.h:557
Input images have incompatible dimensions.
Definition: draw.h:48
std::vector< ImageRef > getDisc(double radius)
returns coordinate for a disc of given radius around the origin.
Definition: draw.cc:29
void copy(const BasicImage< S > &in, BasicImage< T > &out, ImageRef size=ImageRef(-1, -1), ImageRef begin=ImageRef(), ImageRef dst=ImageRef())
Generic image copy function for copying sub rectangles of images into other images.
Definition: utility.h:30
bool next(const ImageRef &max)
Step to the next co-ordinate in the image (in horizontal scanline order).
Definition: image_ref.h:24
static const T & black()
returns pixel value corresponding to minimal saturation
Definition: draw.h:71
static const T & gray()
returns pixel value corresponding to 50% gray
Definition: draw.h:78
void resize(const ImageRef &size)
Resize the image (destroying the data).
Definition: image.h:731
void drawBox(BasicImage< T > &im, const ImageRef &upperleft, const ImageRef &lowerright, const T &c)
draws a box defined by the upper left and the lower right corners into an image
Definition: draw.h:258
traits type defining colors for pixel types
Definition: draw.h:59
int x
The x co-ordinate.
Definition: image_ref.h:172
Base class for all CVD exceptions.
Definition: exceptions.h:15
Definition: image_ref.h:29
void joinImages(const Image< S > &a, const Image< T > &b, Image< U > &J)
joins two images side-by-side to create a larger image, any remaining empty region will be blacked ou...
Definition: draw.h:310
A generic image class to manage a block of arbitrarily padded data as an image.
Definition: image.h:273
Base class for all Image_IO exceptions.
Definition: draw.h:33
int y
The y co-ordinate.
Definition: image_ref.h:173
A full image which manages its own data.
Definition: image.h:623
Input ImageRef not within image dimensions.
Definition: draw.h:40
Definition: builtin_components.h:38
std::vector< ImageRef > getCircle(int radius)
returns coordinate for a circle of given radius around the origin.
Definition: draw.cc:6
static const T & white()
returns pixel value corresponding to maximal saturation
Definition: draw.h:85
void drawCross(BasicImage< T > &im, const ImageRef &p, double len, const T &c)
draws a cross defined by center point and length of the arms into an image
Definition: draw.h:273
void combineImages(const Image< S > &a, const Image< T > &b, Image< U > &out, const ImageRef &dst=ImageRef_zero, ImageRef size=ImageRef(), const ImageRef &from=ImageRef_zero)
similar to copy but combines values from two source images into the output image. ...
Definition: draw.h:339
void drawShape(BasicImage< T > &im, const ImageRef &offset, const std::vector< ImageRef > &points, const T &c)
draws a polyline defined by a set of points into an image.
Definition: draw.h:217
Definition: pixel_traits.h:16
void drawLine(BasicImage< T > &im, double x1, double y1, double x2, double y2, const T &c)
draws a line defined by start and end coordinates with given color into an image. ...
Definition: draw.h:167