36 #ifndef VIGRA_BASICIMAGE_HXX
37 #define VIGRA_BASICIMAGE_HXX
42 #include "iteratortraits.hxx"
43 #include "accessor.hxx"
45 #include "basicimageview.hxx"
48 #ifdef VIGRA_CHECK_BOUNDS
49 #define VIGRA_ASSERT_INSIDE(diff) \
50 vigra_precondition(this->isInside(diff), "Index out of bounds")
52 #define VIGRA_ASSERT_INSIDE(diff)
57 template <
class IMAGEITERATOR>
58 class LineBasedColumnIteratorPolicy
61 typedef IMAGEITERATOR ImageIterator;
62 typedef typename IMAGEITERATOR::LineStartIterator LineStartIterator;
63 typedef typename IMAGEITERATOR::value_type value_type;
64 typedef typename IMAGEITERATOR::difference_type::MoveY
66 typedef typename IMAGEITERATOR::reference reference;
67 typedef typename IMAGEITERATOR::index_reference index_reference;
68 typedef typename IMAGEITERATOR::pointer pointer;
69 typedef std::random_access_iterator_tag iterator_category;
74 explicit BaseType(LineStartIterator c = LineStartIterator(),
75 difference_type o = 0)
76 : line_start_(c), offset_(o)
79 LineStartIterator line_start_;
80 difference_type offset_;
83 static void initialize(BaseType &) {}
85 static reference dereference(BaseType
const & d)
86 {
return const_cast<reference
>(*(*d.line_start_ + d.offset_)); }
88 static index_reference dereference(BaseType
const & d, difference_type n)
90 return const_cast<index_reference
>(*(d.line_start_[n] + d.offset_));
93 static bool equal(BaseType
const & d1, BaseType
const & d2)
94 {
return d1.line_start_ == d2.line_start_; }
96 static bool less(BaseType
const & d1, BaseType
const & d2)
97 {
return d1.line_start_ < d2.line_start_; }
99 static difference_type difference(BaseType
const & d1, BaseType
const & d2)
100 {
return d1.line_start_ - d2.line_start_; }
102 static void increment(BaseType & d)
105 static void decrement(BaseType & d)
108 static void advance(BaseType & d, difference_type n)
109 { d.line_start_ += n; }
124 template <
class IMAGEITERATOR,
class PIXELTYPE,
125 class REFERENCE,
class POINTER,
class LINESTARTITERATOR>
130 PIXELTYPE, REFERENCE, POINTER, LINESTARTITERATOR>
self_type;
132 typedef LINESTARTITERATOR LineStartIterator;
133 typedef PIXELTYPE value_type;
134 typedef PIXELTYPE PixelType;
135 typedef REFERENCE reference;
136 typedef REFERENCE index_reference;
137 typedef POINTER pointer;
139 typedef image_traverser_tag iterator_category;
140 typedef POINTER row_iterator;
144 typedef std::ptrdiff_t MoveX;
145 typedef LINESTARTITERATOR MoveY;
154 return static_cast<IMAGEITERATOR &
>(*this);
161 return static_cast<IMAGEITERATOR &
>(*this);
166 IMAGEITERATOR ret(static_cast<IMAGEITERATOR const &>(*
this));
175 IMAGEITERATOR ret(static_cast<IMAGEITERATOR const &>(*
this));
190 return (x == rhs.x) && (y == rhs.y);
195 return (x != rhs.x) || (y != rhs.y);
198 reference operator*()
const
203 pointer operator->()
const
210 return *(*(y + d.
y) + x + d.
x);
213 index_reference operator()(std::ptrdiff_t dx, std::ptrdiff_t dy)
const
215 return *(*(y + dy) + x + dx);
218 pointer operator[](std::ptrdiff_t dy)
const
223 row_iterator rowIterator()
const
228 typedef typename column_iterator::BaseType Iter;
261 template <
class PIXELTYPE,
class ITERATOR>
264 PIXELTYPE, PIXELTYPE &, PIXELTYPE *, ITERATOR>
269 PIXELTYPE &, PIXELTYPE *, ITERATOR>
Base;
293 template <
class PIXELTYPE,
class ITERATOR>
296 PIXELTYPE, PIXELTYPE const &, PIXELTYPE const *, ITERATOR>
301 PIXELTYPE, PIXELTYPE
const &, PIXELTYPE
const *, ITERATOR>
Base;
333 #ifndef NO_PARTIAL_TEMPLATE_SPECIALIZATION
337 :
public IteratorTraitsBase<BasicImageIterator<T, T**> >
342 typedef DefaultAccessor default_accessor;
343 typedef VigraTrueType hasConstantStrides;
347 struct IteratorTraits<ConstBasicImageIterator<T, T**> >
348 :
public IteratorTraitsBase<ConstBasicImageIterator<T, T**> >
350 typedef BasicImageIterator<T, T**> mutable_iterator;
351 typedef ConstBasicImageIterator<T, T**> const_iterator;
352 typedef typename AccessorTraits<T>::default_const_accessor DefaultAccessor;
353 typedef DefaultAccessor default_accessor;
354 typedef VigraTrueType hasConstantStrides;
357 #else // NO_PARTIAL_TEMPLATE_SPECIALIZATION
359 #define VIGRA_DEFINE_ITERATORTRAITS(VALUETYPE) \
361 struct IteratorTraits<BasicImageIterator<VALUETYPE, VALUETYPE **> > \
362 : public IteratorTraitsBase<BasicImageIterator<VALUETYPE, VALUETYPE **> > \
364 typedef BasicImageIterator<VALUETYPE, VALUETYPE**> mutable_iterator; \
365 typedef ConstBasicImageIterator<VALUETYPE, VALUETYPE**> const_iterator; \
366 typedef typename AccessorTraits<VALUETYPE >::default_accessor DefaultAccessor; \
367 typedef DefaultAccessor default_accessor; \
368 typedef VigraTrueType hasConstantStrides; \
372 struct IteratorTraits<ConstBasicImageIterator<VALUETYPE, VALUETYPE **> > \
373 : public IteratorTraitsBase<ConstBasicImageIterator<VALUETYPE, VALUETYPE **> > \
375 typedef BasicImageIterator<VALUETYPE, VALUETYPE**> mutable_iterator; \
376 typedef ConstBasicImageIterator<VALUETYPE, VALUETYPE**> const_iterator; \
377 typedef typename AccessorTraits<VALUETYPE >::default_const_accessor DefaultAccessor; \
378 typedef DefaultAccessor default_accessor; \
379 typedef VigraTrueType hasConstantStrides; \
382 VIGRA_DEFINE_ITERATORTRAITS(RGBValue<unsigned char>)
383 VIGRA_DEFINE_ITERATORTRAITS(RGBValue<
short>)
384 VIGRA_DEFINE_ITERATORTRAITS(RGBValue<
unsigned short>)
385 VIGRA_DEFINE_ITERATORTRAITS(RGBValue<
int>)
386 VIGRA_DEFINE_ITERATORTRAITS(RGBValue<
unsigned int>)
387 VIGRA_DEFINE_ITERATORTRAITS(RGBValue<
float>)
388 VIGRA_DEFINE_ITERATORTRAITS(RGBValue<
double>)
390 #define VIGRA_PIXELTYPE TinyVector<unsigned char, 2>
391 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
392 #undef VIGRA_PIXELTYPE
393 #define VIGRA_PIXELTYPE TinyVector<unsigned char, 3>
394 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
395 #undef VIGRA_PIXELTYPE
396 #define VIGRA_PIXELTYPE TinyVector<unsigned char, 4>
397 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
398 #undef VIGRA_PIXELTYPE
399 #define VIGRA_PIXELTYPE TinyVector<short, 2>
400 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
401 #undef VIGRA_PIXELTYPE
402 #define VIGRA_PIXELTYPE TinyVector<short, 3>
403 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
404 #undef VIGRA_PIXELTYPE
405 #define VIGRA_PIXELTYPE TinyVector<short, 4>
406 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
407 #undef VIGRA_PIXELTYPE
408 #define VIGRA_PIXELTYPE TinyVector<unsigned short, 2>
409 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
410 #undef VIGRA_PIXELTYPE
411 #define VIGRA_PIXELTYPE TinyVector<unsigned short, 3>
412 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
413 #undef VIGRA_PIXELTYPE
414 #define VIGRA_PIXELTYPE TinyVector<unsigned short, 4>
415 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
416 #undef VIGRA_PIXELTYPE
417 #define VIGRA_PIXELTYPE TinyVector<int, 2>
418 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
419 #undef VIGRA_PIXELTYPE
420 #define VIGRA_PIXELTYPE TinyVector<int, 3>
421 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
422 #undef VIGRA_PIXELTYPE
423 #define VIGRA_PIXELTYPE TinyVector<int, 4>
424 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
425 #undef VIGRA_PIXELTYPE
426 #define VIGRA_PIXELTYPE TinyVector<unsigned int, 2>
427 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
428 #undef VIGRA_PIXELTYPE
429 #define VIGRA_PIXELTYPE TinyVector<unsigned int, 3>
430 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
431 #undef VIGRA_PIXELTYPE
432 #define VIGRA_PIXELTYPE TinyVector<unsigned int, 4>
433 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
434 #undef VIGRA_PIXELTYPE
435 #define VIGRA_PIXELTYPE TinyVector<float, 2>
436 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
437 #undef VIGRA_PIXELTYPE
438 #define VIGRA_PIXELTYPE TinyVector<float, 3>
439 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
440 #undef VIGRA_PIXELTYPE
441 #define VIGRA_PIXELTYPE TinyVector<float, 4>
442 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
443 #undef VIGRA_PIXELTYPE
444 #define VIGRA_PIXELTYPE TinyVector<double, 2>
445 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
446 #undef VIGRA_PIXELTYPE
447 #define VIGRA_PIXELTYPE TinyVector<double, 3>
448 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
449 #undef VIGRA_PIXELTYPE
450 #define VIGRA_PIXELTYPE TinyVector<double, 4>
451 VIGRA_DEFINE_ITERATORTRAITS(VIGRA_PIXELTYPE)
452 #undef VIGRA_PIXELTYPE
454 #undef VIGRA_DEFINE_ITERATORTRAITS
456 #endif // NO_PARTIAL_TEMPLATE_SPECIALIZATION
474 template <
class PIXELTYPE,
class Alloc = std::allocator<PIXELTYPE> >
584 typedef Alloc Allocator;
585 typedef typename Alloc::template rebind<PIXELTYPE *>::other LineAllocator;
614 vigra_precondition((width >= 0) && (height >= 0),
615 "BasicImage::BasicImage(int width, int height): "
616 "width and height must be >= 0.\n");
630 vigra_precondition((size.
x >= 0) && (size.
y >= 0),
631 "BasicImage::BasicImage(Diff2D size): "
632 "size.x and size.y must be >= 0.\n");
649 vigra_precondition((width >= 0) && (height >= 0),
650 "BasicImage::BasicImage(int width, int height, value_type const & ): "
651 "width and height must be >= 0.\n");
660 BasicImage(std::ptrdiff_t width, std::ptrdiff_t height, SkipInitializationTag, Alloc
const & alloc = Alloc())
667 vigra_precondition((width >= 0) && (height >= 0),
668 "BasicImage::BasicImage(int width, int height, value_type const & ): "
669 "width and height must be >= 0.\n");
671 resize(width, height, SkipInitialization);
685 vigra_precondition((size.
x >= 0) && (size.
y >= 0),
686 "BasicImage::BasicImage(Diff2D const & size, value_type const & v): "
687 "size.x and size.y must be >= 0.\n");
702 vigra_precondition((size.
x >= 0) && (size.
y >= 0),
703 "BasicImage::BasicImage(Diff2D const & size, value_type const & v): "
704 "size.x and size.y must be >= 0.\n");
706 resize(size.
x, size.
y, SkipInitialization);
720 vigra_precondition((width >= 0) && (height >= 0),
721 "BasicImage::BasicImage(int width, int height, const_pointer ): "
722 "width and height must be >= 0.\n");
737 vigra_precondition((size.
x >= 0) && (size.
y >= 0),
738 "BasicImage::BasicImage(Diff2D const & size, const_pointer): "
739 "size.x and size.y must be >= 0.\n");
750 allocator_(rhs.allocator_),
751 pallocator_(rhs.pallocator_)
778 void resize(std::ptrdiff_t width, std::ptrdiff_t height)
780 if(width != width_ || height != height_)
789 if(size.
x != width_ || size.
y != height_)
802 resizeImpl(width, height, d,
false);
816 void resize(std::ptrdiff_t width, std::ptrdiff_t height, SkipInitializationTag)
818 resizeImpl(width, height, NumericTraits<value_type>::zero(),
819 CanSkipInitialization<value_type>::value);
863 return d.
x >= 0 && d.
y >= 0 &&
872 VIGRA_ASSERT_INSIDE(d);
873 return lines_[d.
y][d.
x];
881 VIGRA_ASSERT_INSIDE(d);
882 return lines_[d.
y][d.
x];
891 return lines_[dy][dx];
900 return lines_[dy][dx];
927 vigra_precondition(data_ != 0,
928 "BasicImage::upperLeft(): image must have non-zero size.");
938 vigra_precondition(data_ != 0,
939 "BasicImage::lowerRight(): image must have non-zero size.");
947 vigra_precondition(data_ != 0,
948 "BasicImage::upperLeft(): image must have non-zero size.");
958 vigra_precondition(data_ != 0,
959 "BasicImage::lowerRight(): image must have non-zero size.");
967 vigra_precondition(data_ != 0,
968 "BasicImage::begin(): image must have non-zero size.");
976 vigra_precondition(data_ != 0,
977 "BasicImage::end(): image must have non-zero size.");
985 vigra_precondition(data_ != 0,
986 "BasicImage::begin(): image must have non-zero size.");
994 vigra_precondition(data_ != 0,
995 "BasicImage::end(): image must have non-zero size.");
1031 typedef typename column_iterator::BaseType Iter;
1046 typedef typename const_column_iterator::BaseType Iter;
1081 void resizeImpl(std::ptrdiff_t width, std::ptrdiff_t height,
value_type const & d,
bool skipInit);
1087 PIXELTYPE ** lines_;
1088 std::ptrdiff_t width_, height_;
1090 LineAllocator pallocator_;
1093 template <
class PIXELTYPE,
class Alloc>
1094 BasicImage<PIXELTYPE, Alloc> &
1099 if((width() != rhs.
width()) ||
1100 (height() != rhs.
height()))
1110 for(; is != iend; ++is, ++id) *
id = *is;
1116 template <
class PIXELTYPE,
class Alloc>
1123 for(; i != iend; ++i) *i = pixel;
1128 template <
class PIXELTYPE,
class Alloc>
1135 for(; i != iend; ++i) *i = pixel;
1140 template <
class PIXELTYPE,
class Alloc>
1144 vigra_precondition((width >= 0) && (height >= 0),
1145 "BasicImage::resize(int width, int height, value_type const &): "
1146 "width and height must be >= 0.\n");
1147 vigra_precondition(width * height >= 0,
1148 "BasicImage::resize(int width, int height, value_type const &): "
1149 "width * height too large (integer overflow -> negative).\n");
1151 if (width_ != width || height_ != height)
1153 value_type * newdata = 0;
1154 value_type ** newlines = 0;
1155 if(width*height > 0)
1157 if (width*height != width_*height_)
1159 newdata = allocator_.allocate(
typename Alloc::size_type(width*height));
1161 std::uninitialized_fill_n(newdata, width*height, d);
1162 newlines = initLineStartArray(newdata, width, height);
1169 std::fill_n(newdata, width*height, d);
1170 newlines = initLineStartArray(newdata, width, height);
1171 pallocator_.deallocate(lines_,
typename Alloc::size_type(height_));
1184 else if(width*height > 0 && !skipInit)
1186 std::fill_n(data_, width*height, d);
1191 template <
class PIXELTYPE,
class Alloc>
1195 std::ptrdiff_t newsize = width*height;
1196 if (width_ != width || height_ != height)
1202 if (newsize != width_*height_)
1204 newdata = allocator_.allocate(
typename Alloc::size_type(newsize));
1205 std::uninitialized_copy(data, data + newsize, newdata);
1206 newlines = initLineStartArray(newdata, width, height);
1212 std::copy(data, data + newsize, newdata);
1213 newlines = initLineStartArray(newdata, width, height);
1214 pallocator_.deallocate(lines_,
typename Alloc::size_type(height_));
1227 else if(newsize > 0)
1229 std::copy(data, data + newsize, data_);
1233 template <
class PIXELTYPE,
class Alloc>
1239 std::swap( data_, rhs.data_ );
1240 std::swap( lines_, rhs.lines_ );
1241 std::swap( width_, rhs.width_ );
1242 std::swap( height_, rhs.height_ );
1246 template <
class PIXELTYPE,
class Alloc>
1252 ScanOrderIterator i = begin();
1253 ScanOrderIterator iend = end();
1255 for(; i != iend; ++i) (*i).~PIXELTYPE();
1257 allocator_.deallocate(data_,
typename Alloc::size_type(width()*height()));
1258 pallocator_.deallocate(lines_,
typename Alloc::size_type(height_));
1262 template <
class PIXELTYPE,
class Alloc>
1264 BasicImage<PIXELTYPE, Alloc>::initLineStartArray(value_type * data, std::ptrdiff_t width, std::ptrdiff_t height)
1266 value_type ** lines = pallocator_.allocate(
typename Alloc::size_type(height));
1267 for(std::ptrdiff_t y=0; y<height; ++y)
1268 lines[y] = data + y*width;
1278 template <
class PixelType,
class Accessor,
class Alloc>
1279 inline triple<typename BasicImage<PixelType, Alloc>::const_traverser,
1280 typename BasicImage<PixelType, Alloc>::const_traverser, Accessor>
1281 srcImageRange(BasicImage<PixelType, Alloc>
const & img, Accessor a)
1283 return triple<typename BasicImage<PixelType, Alloc>::const_traverser,
1284 typename BasicImage<PixelType, Alloc>::const_traverser,
1285 Accessor>(img.upperLeft(),
1290 template <
class PixelType,
class Accessor,
class Alloc>
1291 inline triple<typename BasicImage<PixelType, Alloc>::const_traverser,
1292 typename BasicImage<PixelType, Alloc>::const_traverser, Accessor>
1293 srcImageRange(BasicImage<PixelType, Alloc>
const & img, Rect2D
const & roi, Accessor a)
1295 vigra_precondition(roi.left() >= 0 && roi.top() >= 0 &&
1296 roi.right() <= img.width() && roi.bottom() <= img.height(),
1297 "srcImageRange(): ROI rectangle outside image.");
1298 return triple<typename BasicImage<PixelType, Alloc>::const_traverser,
1299 typename BasicImage<PixelType, Alloc>::const_traverser,
1300 Accessor>(img.upperLeft() + roi.upperLeft(),
1301 img.upperLeft() + roi.lowerRight(),
1305 template <
class PixelType,
class Accessor,
class Alloc>
1306 inline pair<typename BasicImage<PixelType, Alloc>::const_traverser, Accessor>
1307 srcImage(BasicImage<PixelType, Alloc>
const & img, Accessor a)
1309 return pair<typename BasicImage<PixelType, Alloc>::const_traverser,
1310 Accessor>(img.upperLeft(), a);
1313 template <
class PixelType,
class Accessor,
class Alloc>
1314 inline pair<typename BasicImage<PixelType, Alloc>::const_traverser, Accessor>
1315 srcImage(BasicImage<PixelType, Alloc>
const & img, Point2D
const & ul, Accessor a)
1317 vigra_precondition(img.isInside(ul),
1318 "srcImage(): ROI rectangle outside image.");
1319 return pair<typename BasicImage<PixelType, Alloc>::const_traverser,
1320 Accessor>(img.upperLeft() + ul, a);
1323 template <
class PixelType,
class Accessor,
class Alloc>
1324 inline triple<typename BasicImage<PixelType, Alloc>::traverser,
1325 typename BasicImage<PixelType, Alloc>::traverser, Accessor>
1326 destImageRange(BasicImage<PixelType, Alloc> & img, Accessor a)
1328 return triple<typename BasicImage<PixelType, Alloc>::traverser,
1329 typename BasicImage<PixelType, Alloc>::traverser,
1330 Accessor>(img.upperLeft(),
1335 template <
class PixelType,
class Accessor,
class Alloc>
1336 inline triple<typename BasicImage<PixelType, Alloc>::traverser,
1337 typename BasicImage<PixelType, Alloc>::traverser, Accessor>
1338 destImageRange(BasicImage<PixelType, Alloc> & img, Rect2D
const & roi, Accessor a)
1340 vigra_precondition(roi.left() >= 0 && roi.top() >= 0 &&
1341 roi.right() <= img.width() && roi.bottom() <= img.height(),
1342 "destImageRange(): ROI rectangle outside image.");
1343 return triple<typename BasicImage<PixelType, Alloc>::traverser,
1344 typename BasicImage<PixelType, Alloc>::traverser,
1345 Accessor>(img.upperLeft() + roi.upperLeft(),
1346 img.upperLeft() + roi.lowerRight(),
1350 template <
class PixelType,
class Accessor,
class Alloc>
1351 inline pair<typename BasicImage<PixelType, Alloc>::traverser, Accessor>
1352 destImage(BasicImage<PixelType, Alloc> & img, Accessor a)
1354 return pair<typename BasicImage<PixelType, Alloc>::traverser,
1355 Accessor>(img.upperLeft(), a);
1358 template <
class PixelType,
class Accessor,
class Alloc>
1359 inline pair<typename BasicImage<PixelType, Alloc>::traverser, Accessor>
1360 destImage(BasicImage<PixelType, Alloc> & img, Point2D
const & ul, Accessor a)
1362 vigra_precondition(img.isInside(ul),
1363 "destImage(): ROI rectangle outside image.");
1364 return pair<typename BasicImage<PixelType, Alloc>::traverser,
1365 Accessor>(img.upperLeft() + ul, a);
1368 template <
class PixelType,
class Accessor,
class Alloc>
1369 inline pair<typename BasicImage<PixelType, Alloc>::const_traverser, Accessor>
1370 maskImage(BasicImage<PixelType, Alloc>
const & img, Accessor a)
1372 return pair<typename BasicImage<PixelType, Alloc>::const_traverser,
1373 Accessor>(img.upperLeft(), a);
1376 template <
class PixelType,
class Accessor,
class Alloc>
1377 inline pair<typename BasicImage<PixelType, Alloc>::const_traverser, Accessor>
1378 maskImage(BasicImage<PixelType, Alloc>
const & img, Point2D
const & ul, Accessor a)
1380 vigra_precondition(img.isInside(ul),
1381 "maskImage(): ROI rectangle outside image.");
1382 return pair<typename BasicImage<PixelType, Alloc>::const_traverser,
1383 Accessor>(img.upperLeft() + ul, a);
1388 template <
class PixelType,
class Alloc>
1389 inline triple<typename BasicImage<PixelType, Alloc>::const_traverser,
1390 typename BasicImage<PixelType, Alloc>::const_traverser,
1391 typename BasicImage<PixelType, Alloc>::ConstAccessor>
1392 srcImageRange(BasicImage<PixelType, Alloc>
const & img)
1394 return triple<typename BasicImage<PixelType, Alloc>::const_traverser,
1395 typename BasicImage<PixelType, Alloc>::const_traverser,
1396 typename BasicImage<PixelType, Alloc>::ConstAccessor>(img.upperLeft(),
1401 template <
class PixelType,
class Alloc>
1402 inline triple<typename BasicImage<PixelType, Alloc>::const_traverser,
1403 typename BasicImage<PixelType, Alloc>::const_traverser,
1404 typename BasicImage<PixelType, Alloc>::ConstAccessor>
1405 srcImageRange(BasicImage<PixelType, Alloc>
const & img, Rect2D
const & roi)
1407 vigra_precondition(roi.left() >= 0 && roi.top() >= 0 &&
1408 roi.right() <= img.width() && roi.bottom() <= img.height(),
1409 "srcImageRange(): ROI rectangle outside image.");
1410 return triple<typename BasicImage<PixelType, Alloc>::const_traverser,
1411 typename BasicImage<PixelType, Alloc>::const_traverser,
1412 typename BasicImage<PixelType, Alloc>::ConstAccessor>(img.upperLeft() + roi.upperLeft(),
1413 img.upperLeft() + roi.lowerRight(),
1417 template <
class PixelType,
class Alloc>
1418 inline pair< typename BasicImage<PixelType, Alloc>::const_traverser,
1419 typename BasicImage<PixelType, Alloc>::ConstAccessor>
1420 srcImage(BasicImage<PixelType, Alloc>
const & img)
1422 return pair<typename BasicImage<PixelType, Alloc>::const_traverser,
1423 typename BasicImage<PixelType, Alloc>::ConstAccessor>(img.upperLeft(),
1427 template <
class PixelType,
class Alloc>
1428 inline pair< typename BasicImage<PixelType, Alloc>::const_traverser,
1429 typename BasicImage<PixelType, Alloc>::ConstAccessor>
1430 srcImage(BasicImage<PixelType, Alloc>
const & img, Point2D
const & ul)
1432 vigra_precondition(img.isInside(ul),
1433 "srcImage(): ROI rectangle outside image.");
1434 return pair<typename BasicImage<PixelType, Alloc>::const_traverser,
1435 typename BasicImage<PixelType, Alloc>::ConstAccessor>(img.upperLeft() + ul,
1439 template <
class PixelType,
class Alloc>
1440 inline triple< typename BasicImage<PixelType, Alloc>::traverser,
1441 typename BasicImage<PixelType, Alloc>::traverser,
1442 typename BasicImage<PixelType, Alloc>::Accessor>
1443 destImageRange(BasicImage<PixelType, Alloc> & img)
1445 return triple<typename BasicImage<PixelType, Alloc>::traverser,
1446 typename BasicImage<PixelType, Alloc>::traverser,
1447 typename BasicImage<PixelType, Alloc>::Accessor>(img.upperLeft(),
1452 template <
class PixelType,
class Alloc>
1453 inline triple< typename BasicImage<PixelType, Alloc>::traverser,
1454 typename BasicImage<PixelType, Alloc>::traverser,
1455 typename BasicImage<PixelType, Alloc>::Accessor>
1456 destImageRange(BasicImage<PixelType, Alloc> & img, Rect2D
const & roi)
1458 vigra_precondition(roi.left() >= 0 && roi.top() >= 0 &&
1459 roi.right() <= img.width() && roi.bottom() <= img.height(),
1460 "destImageRange(): ROI rectangle outside image.");
1461 return triple<typename BasicImage<PixelType, Alloc>::traverser,
1462 typename BasicImage<PixelType, Alloc>::traverser,
1463 typename BasicImage<PixelType, Alloc>::Accessor>(img.upperLeft() + roi.upperLeft(),
1464 img.upperLeft() + roi.lowerRight(),
1468 template <
class PixelType,
class Alloc>
1469 inline pair< typename BasicImage<PixelType, Alloc>::traverser,
1470 typename BasicImage<PixelType, Alloc>::Accessor>
1471 destImage(BasicImage<PixelType, Alloc> & img)
1473 return pair<typename BasicImage<PixelType, Alloc>::traverser,
1474 typename BasicImage<PixelType, Alloc>::Accessor>(img.upperLeft(),
1478 template <
class PixelType,
class Alloc>
1479 inline pair< typename BasicImage<PixelType, Alloc>::traverser,
1480 typename BasicImage<PixelType, Alloc>::Accessor>
1481 destImage(BasicImage<PixelType, Alloc> & img, Point2D
const & ul)
1483 vigra_precondition(img.isInside(ul),
1484 "destImage(): ROI rectangle outside image.");
1485 return pair<typename BasicImage<PixelType, Alloc>::traverser,
1486 typename BasicImage<PixelType, Alloc>::Accessor>(img.upperLeft() + ul,
1490 template <
class PixelType,
class Alloc>
1491 inline pair< typename BasicImage<PixelType, Alloc>::const_traverser,
1492 typename BasicImage<PixelType, Alloc>::ConstAccessor>
1493 maskImage(BasicImage<PixelType, Alloc>
const & img)
1495 return pair<typename BasicImage<PixelType, Alloc>::const_traverser,
1496 typename BasicImage<PixelType, Alloc>::ConstAccessor>(img.upperLeft(),
1500 template <
class PixelType,
class Alloc>
1501 inline pair< typename BasicImage<PixelType, Alloc>::const_traverser,
1502 typename BasicImage<PixelType, Alloc>::ConstAccessor>
1503 maskImage(BasicImage<PixelType, Alloc>
const & img, Point2D
const & ul)
1505 vigra_precondition(img.isInside(ul),
1506 "maskImage(): ROI rectangle outside image.");
1507 return pair<typename BasicImage<PixelType, Alloc>::const_traverser,
1508 typename BasicImage<PixelType, Alloc>::ConstAccessor>(img.upperLeft() + ul,
1513 #undef VIGRA_ASSERT_INSIDE
1514 #endif // VIGRA_BASICIMAGE_HXX
iterator end()
Definition: basicimage.hxx:974
iterator begin()
Definition: basicimage.hxx:965
int MoveY
Definition: diff2d.hxx:229
ConstBasicImageIterator< PIXELTYPE, PIXELTYPE ** > ConstIterator
Definition: basicimage.hxx:544
const_traverser::column_iterator const_column_iterator
Definition: basicimage.hxx:560
Export associated information for each image iterator.
Definition: iteratortraits.hxx:109
row_iterator rowEnd(std::ptrdiff_t y)
Definition: basicimage.hxx:1008
Accessor accessor()
Definition: basicimage.hxx:1066
const_iterator begin() const
Definition: basicimage.hxx:983
const_iterator end() const
Definition: basicimage.hxx:992
PIXELTYPE & reference
Definition: basicimage.hxx:490
const_reference operator()(std::ptrdiff_t dx, std::ptrdiff_t dy) const
Definition: basicimage.hxx:897
int y
Definition: diff2d.hxx:392
size_type size() const
Definition: basicimage.hxx:854
BasicImage(difference_type const &size, SkipInitializationTag, Alloc const &alloc=Alloc())
Definition: basicimage.hxx:695
IteratorTraits< traverser >::DefaultAccessor Accessor
Definition: basicimage.hxx:573
const_pointer operator[](std::ptrdiff_t dy) const
Definition: basicimage.hxx:917
BasicImage(std::ptrdiff_t width, std::ptrdiff_t height, value_type const &d, Alloc const &alloc=Alloc())
Definition: basicimage.hxx:642
BasicImage & init(value_type const &pixel)
Definition: basicimage.hxx:1130
int x
Definition: diff2d.hxx:385
const_reference operator[](difference_type const &d) const
Definition: basicimage.hxx:879
PIXELTYPE const & const_reference
Definition: basicimage.hxx:496
BasicImage(difference_type const &size, const_pointer d, Alloc const &alloc=Alloc())
Definition: basicimage.hxx:730
column_iterator columnEnd(std::ptrdiff_t x)
Definition: basicimage.hxx:1037
BasicImage()
Definition: basicimage.hxx:589
Two dimensional difference vector.
Definition: diff2d.hxx:185
void resize(std::ptrdiff_t width, std::ptrdiff_t height, SkipInitializationTag)
Definition: basicimage.hxx:816
PIXELTYPE * pointer
Definition: basicimage.hxx:500
traverser::column_iterator column_iterator
Definition: basicimage.hxx:556
PIXELTYPE const * ConstScanOrderIterator
Definition: basicimage.hxx:524
std::ptrdiff_t height() const
Definition: basicimage.hxx:847
BasicImageIterator< PIXELTYPE, PIXELTYPE ** > traverser
Definition: basicimage.hxx:528
Two dimensional size object.
Definition: diff2d.hxx:482
BasicImage(std::ptrdiff_t width, std::ptrdiff_t height, SkipInitializationTag, Alloc const &alloc=Alloc())
Definition: basicimage.hxx:660
BasicImage(const BasicImage &rhs)
Definition: basicimage.hxx:746
Definition: basicimage.hxx:262
column_iterator columnBegin(std::ptrdiff_t x)
Definition: basicimage.hxx:1029
const_row_iterator rowEnd(std::ptrdiff_t y) const
Definition: basicimage.hxx:1022
const_column_iterator columnEnd(std::ptrdiff_t x) const
Definition: basicimage.hxx:1052
BasicImageIterator< PIXELTYPE, PIXELTYPE ** > Iterator
Definition: basicimage.hxx:532
BasicImage(std::ptrdiff_t width, std::ptrdiff_t height, Alloc const &alloc=Alloc())
Definition: basicimage.hxx:607
PIXELTYPE const * const_pointer
Definition: basicimage.hxx:504
const_column_iterator columnBegin(std::ptrdiff_t x) const
Definition: basicimage.hxx:1044
void swap(BasicImage &rhs)
Definition: basicimage.hxx:1235
Alloc allocator_type
Definition: basicimage.hxx:582
Definition: basicimage.hxx:126
BasicImage(difference_type const &size, value_type const &d, Alloc const &alloc=Alloc())
Definition: basicimage.hxx:678
int MoveX
Definition: diff2d.hxx:226
reference operator()(std::ptrdiff_t dx, std::ptrdiff_t dy)
Definition: basicimage.hxx:888
const_pointer data() const
Definition: basicimage.hxx:1059
pointer operator[](std::ptrdiff_t dy)
Definition: basicimage.hxx:907
bool isInside(difference_type const &d) const
Definition: basicimage.hxx:861
const_traverser::row_iterator const_row_iterator
Definition: basicimage.hxx:552
PIXELTYPE const * const_iterator
Definition: basicimage.hxx:520
Size2D size_type
Definition: basicimage.hxx:568
IteratorTraits< const_traverser >::DefaultAccessor ConstAccessor
Definition: basicimage.hxx:578
void resize(std::ptrdiff_t width, std::ptrdiff_t height, value_type const &d)
Definition: basicimage.hxx:800
traverser lowerRight()
Definition: basicimage.hxx:936
PIXELTYPE PixelType
Definition: basicimage.hxx:485
ConstBasicImageIterator< PIXELTYPE, PIXELTYPE ** > const_traverser
Definition: basicimage.hxx:538
const_traverser lowerRight() const
Definition: basicimage.hxx:956
BasicImage(difference_type const &size, Alloc const &alloc=Alloc())
Definition: basicimage.hxx:623
Fundamental class template for images.
Definition: basicimage.hxx:475
PIXELTYPE * ScanOrderIterator
Definition: basicimage.hxx:514
BasicImage(std::ptrdiff_t width, std::ptrdiff_t height, const_pointer d, Alloc const &alloc=Alloc())
Definition: basicimage.hxx:713
Definition: basicimage.hxx:294
void resize(std::ptrdiff_t width, std::ptrdiff_t height)
Definition: basicimage.hxx:778
void resizeCopy(std::ptrdiff_t width, std::ptrdiff_t height, const_pointer data)
Definition: basicimage.hxx:1193
row_iterator rowBegin(std::ptrdiff_t y)
Definition: basicimage.hxx:1001
traverser::row_iterator row_iterator
Definition: basicimage.hxx:548
reference operator[](difference_type const &d)
Definition: basicimage.hxx:870
~BasicImage()
Definition: basicimage.hxx:758
void resizeCopy(const BasicImage &rhs)
Definition: basicimage.hxx:829
Diff2D difference_type
Definition: basicimage.hxx:564
Encapsulate access to the values an iterator points to.
Definition: accessor.hxx:133
Quickly create 1-dimensional iterator adapters.
Definition: iteratoradapter.hxx:147
std::ptrdiff_t width() const
Definition: basicimage.hxx:840
BasicImage & operator=(const BasicImage &rhs)
Definition: basicimage.hxx:1095
void resize(difference_type const &size)
Definition: basicimage.hxx:787
BasicImage(Alloc const &alloc)
Definition: basicimage.hxx:597
ConstAccessor accessor() const
Definition: basicimage.hxx:1073
const_traverser upperLeft() const
Definition: basicimage.hxx:945
PIXELTYPE value_type
Definition: basicimage.hxx:481
traverser upperLeft()
Definition: basicimage.hxx:925
PIXELTYPE * iterator
Definition: basicimage.hxx:510
const_row_iterator rowBegin(std::ptrdiff_t y) const
Definition: basicimage.hxx:1015