[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

vigra/basicimageview.hxx |

    00001 /************************************************************************/
    00002 /*                                                                      */
    00003 /*               Copyright 1998-2002 by Ullrich Koethe                  */
    00004 /*                                                                      */
    00005 /*    This file is part of the VIGRA computer vision library.           */
    00006 /*    The VIGRA Website is                                              */
    00007 /*        http://hci.iwr.uni-heidelberg.de/vigra/                       */
    00008 /*    Please direct questions, bug reports, and contributions to        */
    00009 /*        ullrich.koethe@iwr.uni-heidelberg.de    or                    */
    00010 /*        vigra@informatik.uni-hamburg.de                               */
    00011 /*                                                                      */
    00012 /*    Permission is hereby granted, free of charge, to any person       */
    00013 /*    obtaining a copy of this software and associated documentation    */
    00014 /*    files (the "Software"), to deal in the Software without           */
    00015 /*    restriction, including without limitation the rights to use,      */
    00016 /*    copy, modify, merge, publish, distribute, sublicense, and/or      */
    00017 /*    sell copies of the Software, and to permit persons to whom the    */
    00018 /*    Software is furnished to do so, subject to the following          */
    00019 /*    conditions:                                                       */
    00020 /*                                                                      */
    00021 /*    The above copyright notice and this permission notice shall be    */
    00022 /*    included in all copies or substantial portions of the             */
    00023 /*    Software.                                                         */
    00024 /*                                                                      */
    00025 /*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND    */
    00026 /*    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES   */
    00027 /*    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND          */
    00028 /*    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT       */
    00029 /*    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,      */
    00030 /*    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      */
    00031 /*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR     */
    00032 /*    OTHER DEALINGS IN THE SOFTWARE.                                   */
    00033 /*                                                                      */
    00034 /************************************************************************/
    00035
    00036 #ifndef VIGRA_BASICIMAGEVIEW_HXX
    00037 #define VIGRA_BASICIMAGEVIEW_HXX
    00038
    00039 #include "imageiterator.hxx"
    00040 #include "initimage.hxx"
    00041
    00042 // Bounds checking Macro used if VIGRA_CHECK_BOUNDS is defined.
    00043 #ifdef VIGRA_CHECK_BOUNDS
    00044 #define VIGRA_ASSERT_INSIDE(diff) \
    00045   vigra_precondition(this->isInside(diff), "Index out of bounds")
    00046 #else
    00047 #define VIGRA_ASSERT_INSIDE(diff)
    00048 #endif
    00049
    00050
    00051 namespace vigra {
    00052
    00053
    00054 /********************************************************/
    00055 /*                                                      */
    00056 /*                     BasicImageView                   */
    00057 /*                                                      */
    00058 /********************************************************/
    00059
    00060 /** \brief BasicImage using foreign memory.
    00061
    00062     This class provides the same interface as \ref vigra::BasicImage
    00063     (with the exception of <tt>resize()</tt>) but the image's
    00064     memory is provided from the outside instead of allocated internally.
    00065
    00066     A <tt>BasicImageView</tt> can also be created from a
    00067     \ref vigra::MultiArrayView with the appropriate shape -- see
    00068     \ref MultiArrayToImage.
    00069
    00070     <b>\#include</b> <<a href="basicimageview_8hxx-source.html">vigra/basicimageview.hxx</a>>
    00071
    00072     Namespace: vigra
    00073 */
    00074 template <class PIXELTYPE>
    00075 class BasicImageView
    00076 {
    00077   public:
    00078
    00079         /** the BasicImageView's pixel type
    00080         */
    00081     typedef PIXELTYPE value_type;
    00082
    00083         /** the BasicImageView's pixel type
    00084         */
    00085     typedef PIXELTYPE PixelType;
    00086
    00087         /** the BasicImageView's reference type (i.e. the
    00088             return type of image[diff] and image(dx,dy))
    00089         */
    00090     typedef PIXELTYPE &       reference;
    00091
    00092         /** the BasicImageView's const reference type (i.e. the
    00093             return type of image[diff] and image(dx,dy) when image is const)
    00094         */
    00095     typedef PIXELTYPE const & const_reference;
    00096
    00097         /** the BasicImageView's pointer type
    00098         */
    00099     typedef PIXELTYPE *       pointer;
    00100
    00101         /** the BasicImageView's const pointer type
    00102         */
    00103     typedef PIXELTYPE const * const_pointer;
    00104
    00105         /** the BasicImageView's 1D random access iterator
    00106             (note: lower case 'iterator' is a STL compatible 1D random
    00107              access iterator, don't confuse with capitalized Iterator)
    00108         */
    00109     typedef PIXELTYPE * iterator;
    00110
    00111         /** deprecated, use <TT>iterator</TT> instead
    00112         */
    00113     typedef PIXELTYPE * ScanOrderIterator;
    00114
    00115         /** the BasicImageView's 1D random access const iterator
    00116             (note: lower case 'const_iterator' is a STL compatible 1D
    00117             random access const iterator)
    00118         */
    00119     typedef PIXELTYPE const * const_iterator;
    00120
    00121         /** deprecated, use <TT>const_iterator</TT> instead
    00122         */
    00123     typedef PIXELTYPE const * ConstScanOrderIterator;
    00124
    00125         /** the BasicImageView's 2D random access iterator ('traverser')
    00126         */
    00127     typedef ImageIterator<value_type> traverser;
    00128
    00129         /** deprecated, use <TT>traverser</TT> instead
    00130         */
    00131     typedef ImageIterator<value_type> Iterator;
    00132
    00133         /** the BasicImageView's 2D random access const iterator ('const traverser')
    00134         */
    00135     typedef ConstImageIterator<value_type> const_traverser;
    00136
    00137         /** deprecated, use <TT>const_traverser</TT> instead
    00138         */
    00139     typedef ConstImageIterator<value_type> ConstIterator;
    00140
    00141         /** the row iterator associated with the traverser
    00142         */
    00143     typedef typename traverser::row_iterator row_iterator;
    00144
    00145         /** the const row iterator associated with the const_traverser
    00146         */
    00147     typedef typename const_traverser::row_iterator const_row_iterator;
    00148
    00149         /** the column iterator associated with the traverser
    00150         */
    00151     typedef typename traverser::column_iterator column_iterator;
    00152
    00153         /** the const column iterator associated with the const_traverser
    00154         */
    00155     typedef typename const_traverser::column_iterator const_column_iterator;
    00156
    00157         /** the BasicImageView's difference type (argument type of image[diff])
    00158         */
    00159     typedef Diff2D difference_type;
    00160
    00161          /** the BasicImageView's size type (result type of image.size())
    00162         */
    00163     typedef Size2D size_type;
    00164
    00165        /** the BasicImageView's default accessor
    00166         */
    00167     typedef typename
    00168           IteratorTraits<traverser>::DefaultAccessor Accessor;
    00169
    00170         /** the BasicImageView's default const accessor
    00171         */
    00172     typedef typename
    00173           IteratorTraits<const_traverser>::DefaultAccessor ConstAccessor;
    00174
    00175         /** construct image of size 0x0
    00176         */
    00177     BasicImageView()
    00178     : data_(0),
    00179       width_(0),
    00180       height_(0),
    00181       stride_(0)
    00182     {}
    00183
    00184         /** construct view of size w x h
    00185         */
    00186     BasicImageView(const_pointer data, int w, int h, int stride = 0)
    00187     : data_(const_cast<pointer>(data)),
    00188       width_(w),
    00189       height_(h),
    00190       stride_(stride == 0 ? w : stride)
    00191     {}
    00192
    00193         /** construct view of size size.x x size.y
    00194         */
    00195     BasicImageView(const_pointer data, difference_type const & size, int stride = 0)
    00196     : data_(const_cast<pointer>(data)),
    00197       width_(size.x),
    00198       height_(size.y),
    00199       stride_(stride == 0 ? size.x : stride)
    00200     {}
    00201
    00202         /** set Image with const value
    00203         */
    00204     BasicImageView & init(value_type const & pixel)
    00205     {
    00206         initImage(upperLeft(), lowerRight(), accessor(), pixel);
    00207
    00208         return *this;
    00209     }
    00210
    00211         /** width of Image
    00212         */
    00213     int width() const
    00214     {
    00215         return width_;
    00216     }
    00217
    00218         /** height of Image
    00219         */
    00220     int height() const
    00221     {
    00222         return height_;
    00223     }
    00224
    00225         /** stride of Image.
    00226             Memory offset between the start of two successive rows.
    00227         */
    00228     int stride() const
    00229     {
    00230         return stride_;
    00231     }
    00232
    00233         /** size of Image
    00234         */
    00235     size_type size() const
    00236     {
    00237         return size_type(width(), height());
    00238     }
    00239
    00240         /** test whether a given coordinate is inside the image
    00241         */
    00242     bool isInside(difference_type const & d) const
    00243     {
    00244         return d.x >= 0 && d.y >= 0 &&
    00245                d.x < width() && d.y < height();
    00246     }
    00247
    00248         /** access pixel at given location. <br>
    00249         usage: <TT> value_type value = image[Diff2D(1,2)] </TT>
    00250         */
    00251     reference operator[](difference_type const & d)
    00252     {
    00253         VIGRA_ASSERT_INSIDE(d);
    00254         return data_[d.y*stride_ + d.x];
    00255     }
    00256
    00257         /** read pixel at given location. <br>
    00258         usage: <TT> value_type value = image[Diff2D(1,2)] </TT>
    00259         */
    00260     const_reference operator[](difference_type const & d) const
    00261     {
    00262         VIGRA_ASSERT_INSIDE(difference_type(d));
    00263         return data_[d.y*stride_ + d.x];
    00264     }
    00265
    00266         /** access pixel at given location. <br>
    00267         usage: <TT> value_type value = image(1,2) </TT>
    00268         */
    00269     reference operator()(int dx, int dy)
    00270     {
    00271         VIGRA_ASSERT_INSIDE(difference_type(dx,dy));
    00272         return data_[dy*stride_ + dx];
    00273     }
    00274
    00275         /** read pixel at given location. <br>
    00276         usage: <TT> value_type value = image(1,2) </TT>
    00277         */
    00278     const_reference operator()(int dx, int dy) const
    00279     {
    00280         VIGRA_ASSERT_INSIDE(difference_type(dx, dy));
    00281         return data_[dy*stride_ + dx];
    00282     }
    00283
    00284         /** access pixel at given location.
    00285             Note that the 'x' index is the trailing index. <br>
    00286         usage: <TT> value_type value = image[2][1] </TT>
    00287         */
    00288     pointer operator[](int dy)
    00289     {
    00290         VIGRA_ASSERT_INSIDE(difference_type(0, dy));
    00291         return data_ + dy*stride_;
    00292     }
    00293
    00294         /** read pixel at given location.
    00295             Note that the 'x' index is the trailing index. <br>
    00296         usage: <TT> value_type value = image[2][1] </TT>
    00297         */
    00298     const_pointer operator[](int dy) const
    00299     {
    00300         VIGRA_ASSERT_INSIDE(difference_type(0,dy));
    00301         return data_ + dy*stride_;
    00302     }
    00303
    00304         /** init 2D random access iterator poining to upper left pixel
    00305         */
    00306     traverser upperLeft()
    00307     {
    00308         return traverser(data_, stride_);
    00309     }
    00310
    00311         /** init 2D random access iterator poining to
    00312          pixel(width, height), i.e. one pixel right and below lower right
    00313          corner of the image as is common in C/C++.
    00314         */
    00315     traverser lowerRight()
    00316     {
    00317         return upperLeft() + size();
    00318     }
    00319
    00320         /** init 2D random access const iterator poining to upper left pixel
    00321         */
    00322     const_traverser upperLeft() const
    00323     {
    00324         return const_traverser(data_, stride_);
    00325     }
    00326
    00327         /** init 2D random access const iterator poining to
    00328          pixel(width, height), i.e. one pixel right and below lower right
    00329          corner of the image as is common in C/C++.
    00330         */
    00331     const_traverser lowerRight() const
    00332     {
    00333         return upperLeft() + size();
    00334     }
    00335
    00336         /** init 1D random access iterator pointing to first pixel.
    00337             Note: Only works if stride equals width.
    00338         */
    00339     iterator begin()
    00340     {
    00341         vigra_precondition(stride_ == width_,
    00342             "BasicImageView::begin(): "
    00343             "can only create scan order iterator if width() == stride().");
    00344         return data_;
    00345     }
    00346
    00347         /** init 1D random access iterator pointing past the end.
    00348             Note: Only works if stride equals width.
    00349         */
    00350     iterator end()
    00351     {
    00352         vigra_precondition(stride_ == width_,
    00353             "BasicImageView::end(): "
    00354             "can only create scan order iterator if width() == stride().");
    00355         return data_ + width() * height();
    00356     }
    00357
    00358         /** init 1D random access const iterator pointing to first pixel.
    00359             Note: Only works if stride equals width.
    00360         */
    00361     const_iterator begin() const
    00362     {
    00363         vigra_precondition(stride_ == width_,
    00364             "BasicImageView::begin(): "
    00365             "can only create scan order iterator if width() == stride().");
    00366         return data_;
    00367     }
    00368
    00369         /** init 1D random access const iterator pointing past the end.
    00370             Note: Only works if stride equals width.
    00371         */
    00372     const_iterator end() const
    00373     {
    00374         vigra_precondition(stride_ == width_,
    00375             "BasicImageView::end(): "
    00376             "can only create scan order iterator if width() == stride().");
    00377         return data_ + width() * height();
    00378     }
    00379
    00380         /** init 1D random access iterator pointing to first pixel of row \a y
    00381         */
    00382     row_iterator rowBegin(int y)
    00383     {
    00384         return data_ + stride_ * y;
    00385     }
    00386
    00387         /** init 1D random access iterator pointing past the end of row \a y
    00388         */
    00389     row_iterator rowEnd(int y)
    00390     {
    00391         return rowBegin(y) + width();
    00392     }
    00393
    00394         /** init 1D random access const iterator pointing to first pixel of row \a y
    00395         */
    00396     const_row_iterator rowBegin(int y) const
    00397     {
    00398         return data_ + stride_ * y;
    00399     }
    00400
    00401         /** init 1D random access const iterator pointing past the end of row \a y
    00402         */
    00403     const_row_iterator rowEnd(int y) const
    00404     {
    00405         return rowBegin(y) + width();
    00406     }
    00407
    00408         /** init 1D random access iterator pointing to first pixel of column \a x
    00409         */
    00410     column_iterator columnBegin(int x)
    00411     {
    00412         typedef typename column_iterator::BaseType Iter;
    00413         return column_iterator(Iter(data_ + x, stride_));
    00414     }
    00415
    00416         /** init 1D random access iterator pointing past the end of column \a x
    00417         */
    00418     column_iterator columnEnd(int x)
    00419     {
    00420         return columnBegin(x) + height();
    00421     }
    00422
    00423         /** init 1D random access const iterator pointing to first pixel of column \a x
    00424         */
    00425     const_column_iterator columnBegin(int x) const
    00426     {
    00427         typedef typename const_column_iterator::BaseType Iter;
    00428         return const_column_iterator(Iter(data_ + x, stride_));
    00429     }
    00430
    00431         /** init 1D random access const iterator pointing past the end of column \a x
    00432         */
    00433     const_column_iterator columnEnd(int x) const
    00434     {
    00435         return columnBegin(x) + height();
    00436     }
    00437
    00438         /** get a pointer to the internal data
    00439         */
    00440     const_pointer data() const
    00441     {
    00442         return data_;
    00443     }
    00444
    00445         /** return default accessor
    00446         */
    00447     Accessor accessor()
    00448     {
    00449         return Accessor();
    00450     }
    00451
    00452         /** return default const accessor
    00453         */
    00454     ConstAccessor accessor() const
    00455     {
    00456         return ConstAccessor();
    00457     }
    00458
    00459   private:
    00460
    00461     pointer data_;
    00462     int width_, height_, stride_;
    00463 };
    00464
    00465
    00466 /********************************************************/
    00467 /*                                                      */
    00468 /*              argument object factories               */
    00469 /*                                                      */
    00470 /********************************************************/
    00471
    00472 template <class PixelType, class Accessor>
    00473 inline triple<typename BasicImageView<PixelType>::const_traverser,
    00474               typename BasicImageView<PixelType>::const_traverser, Accessor>
    00475 srcImageRange(BasicImageView<PixelType> const & img, Accessor a)
    00476 {
    00477     return triple<typename BasicImageView<PixelType>::const_traverser,
    00478                   typename BasicImageView<PixelType>::const_traverser,
    00479           Accessor>(img.upperLeft(),
    00480                     img.lowerRight(),
    00481                     a);
    00482 }
    00483
    00484 template <class PixelType, class Accessor>
    00485 inline triple<typename BasicImageView<PixelType>::const_traverser,
    00486               typename BasicImageView<PixelType>::const_traverser, Accessor>
    00487 srcImageRange(BasicImageView<PixelType> const & img, Rect2D const & roi, Accessor a)
    00488 {
    00489     vigra_precondition(roi.left() >= 0 && roi.top() >= 0 &&
    00490                        roi.right() <= img.width() && roi.bottom() <= img.height(),
    00491                        "srcImageRange(): ROI rectangle outside image.");
    00492     return triple<typename BasicImageView<PixelType>::const_traverser,
    00493                   typename BasicImageView<PixelType>::const_traverser,
    00494           Accessor>(img.upperLeft() + roi.upperLeft(),
    00495                     img.upperLeft() + roi.lowerRight(),
    00496                     a);
    00497 }
    00498
    00499 template <class PixelType, class Accessor>
    00500 inline pair<typename BasicImageView<PixelType>::const_traverser, Accessor>
    00501 srcImage(BasicImageView<PixelType> const & img, Accessor a)
    00502 {
    00503     return pair<typename BasicImageView<PixelType>::const_traverser,
    00504                 Accessor>(img.upperLeft(), a);
    00505 }
    00506
    00507 template <class PixelType, class Accessor>
    00508 inline pair<typename BasicImageView<PixelType>::const_traverser, Accessor>
    00509 srcImage(BasicImageView<PixelType> const & img, Point2D const & ul, Accessor a)
    00510 {
    00511     vigra_precondition(img.isInside(ul),
    00512                        "srcImage(): ROI rectangle outside image.");
    00513     return pair<typename BasicImageView<PixelType>::const_traverser,
    00514                 Accessor>(img.upperLeft() + ul, a);
    00515 }
    00516
    00517 template <class PixelType, class Accessor>
    00518 inline triple<typename BasicImageView<PixelType>::traverser,
    00519               typename BasicImageView<PixelType>::traverser, Accessor>
    00520 destImageRange(BasicImageView<PixelType> & img, Accessor a)
    00521 {
    00522     return triple<typename BasicImageView<PixelType>::traverser,
    00523                   typename BasicImageView<PixelType>::traverser,
    00524           Accessor>(img.upperLeft(),
    00525                     img.lowerRight(),
    00526                     a);
    00527 }
    00528
    00529 template <class PixelType, class Accessor>
    00530 inline triple<typename BasicImageView<PixelType>::traverser,
    00531               typename BasicImageView<PixelType>::traverser, Accessor>
    00532 destImageRange(BasicImageView<PixelType> & img, Rect2D const & roi, Accessor a)
    00533 {
    00534     vigra_precondition(roi.left() >= 0 && roi.top() >= 0 &&
    00535                        roi.right() <= img.width() && roi.bottom() <= img.height(),
    00536                        "destImageRange(): ROI rectangle outside image.");
    00537     return triple<typename BasicImageView<PixelType>::traverser,
    00538                   typename BasicImageView<PixelType>::traverser,
    00539           Accessor>(img.upperLeft() + roi.upperLeft(),
    00540                     img.upperLeft() + roi.lowerRight(),
    00541                     a);
    00542 }
    00543
    00544 template <class PixelType, class Accessor>
    00545 inline pair<typename BasicImageView<PixelType>::traverser, Accessor>
    00546 destImage(BasicImageView<PixelType> & img, Accessor a)
    00547 {
    00548     return pair<typename BasicImageView<PixelType>::traverser,
    00549                 Accessor>(img.upperLeft(), a);
    00550 }
    00551
    00552 template <class PixelType, class Accessor>
    00553 inline pair<typename BasicImageView<PixelType>::traverser, Accessor>
    00554 destImage(BasicImageView<PixelType> & img, Point2D const & ul, Accessor a)
    00555 {
    00556     vigra_precondition(img.isInside(ul),
    00557                        "destImage(): ROI rectangle outside image.");
    00558     return pair<typename BasicImageView<PixelType>::traverser,
    00559                 Accessor>(img.upperLeft() + ul, a);
    00560 }
    00561
    00562 template <class PixelType, class Accessor>
    00563 inline pair<typename BasicImageView<PixelType>::const_traverser, Accessor>
    00564 maskImage(BasicImageView<PixelType> const & img, Accessor a)
    00565 {
    00566     return pair<typename BasicImageView<PixelType>::const_traverser,
    00567                 Accessor>(img.upperLeft(), a);
    00568 }
    00569
    00570 template <class PixelType, class Accessor>
    00571 inline pair<typename BasicImageView<PixelType>::const_traverser, Accessor>
    00572 maskImage(BasicImageView<PixelType> const & img, Point2D const & ul, Accessor a)
    00573 {
    00574     vigra_precondition(img.isInside(ul),
    00575                        "maskImage(): ROI rectangle outside image.");
    00576     return pair<typename BasicImageView<PixelType>::const_traverser,
    00577                 Accessor>(img.upperLeft() + ul, a);
    00578 }
    00579
    00580 /****************************************************************/
    00581
    00582 template <class PixelType>
    00583 inline triple<typename BasicImageView<PixelType>::const_traverser,
    00584               typename BasicImageView<PixelType>::const_traverser,
    00585               typename BasicImageView<PixelType>::ConstAccessor>
    00586 srcImageRange(BasicImageView<PixelType> const & img)
    00587 {
    00588     return triple<typename BasicImageView<PixelType>::const_traverser,
    00589                   typename BasicImageView<PixelType>::const_traverser,
    00590                   typename BasicImageView<PixelType>::ConstAccessor>(img.upperLeft(),
    00591                                                                         img.lowerRight(),
    00592                                                                         img.accessor());
    00593 }
    00594
    00595 template <class PixelType>
    00596 inline triple<typename BasicImageView<PixelType>::const_traverser,
    00597               typename BasicImageView<PixelType>::const_traverser,
    00598               typename BasicImageView<PixelType>::ConstAccessor>
    00599 srcImageRange(BasicImageView<PixelType> const & img, Rect2D const & roi)
    00600 {
    00601     vigra_precondition(roi.left() >= 0 && roi.top() >= 0 &&
    00602                        roi.right() <= img.width() && roi.bottom() <= img.height(),
    00603                        "srcImageRange(): ROI rectangle outside image.");
    00604     return triple<typename BasicImageView<PixelType>::const_traverser,
    00605                   typename BasicImageView<PixelType>::const_traverser,
    00606                   typename BasicImageView<PixelType>::ConstAccessor>(img.upperLeft() + roi.upperLeft(),
    00607                                                                         img.upperLeft() + roi.lowerRight(),
    00608                                                                         img.accessor());
    00609 }
    00610
    00611 template <class PixelType>
    00612 inline pair< typename BasicImageView<PixelType>::const_traverser,
    00613              typename BasicImageView<PixelType>::ConstAccessor>
    00614 srcImage(BasicImageView<PixelType> const & img)
    00615 {
    00616     return pair<typename BasicImageView<PixelType>::const_traverser,
    00617                 typename BasicImageView<PixelType>::ConstAccessor>(img.upperLeft(),
    00618                                                                       img.accessor());
    00619 }
    00620
    00621 template <class PixelType>
    00622 inline pair< typename BasicImageView<PixelType>::const_traverser,
    00623              typename BasicImageView<PixelType>::ConstAccessor>
    00624 srcImage(BasicImageView<PixelType> const & img, Point2D const & ul)
    00625 {
    00626     vigra_precondition(img.isInside(ul),
    00627                        "srcImage(): ROI rectangle outside image.");
    00628     return pair<typename BasicImageView<PixelType>::const_traverser,
    00629                 typename BasicImageView<PixelType>::ConstAccessor>(img.upperLeft() + ul,
    00630                                                                       img.accessor());
    00631 }
    00632
    00633 template <class PixelType>
    00634 inline triple< typename BasicImageView<PixelType>::traverser,
    00635                typename BasicImageView<PixelType>::traverser,
    00636                typename BasicImageView<PixelType>::Accessor>
    00637 destImageRange(BasicImageView<PixelType> & img)
    00638 {
    00639     return triple<typename BasicImageView<PixelType>::traverser,
    00640                   typename BasicImageView<PixelType>::traverser,
    00641                   typename BasicImageView<PixelType>::Accessor>(img.upperLeft(),
    00642                                                                    img.lowerRight(),
    00643                                                                    img.accessor());
    00644 }
    00645
    00646 template <class PixelType>
    00647 inline triple< typename BasicImageView<PixelType>::traverser,
    00648                typename BasicImageView<PixelType>::traverser,
    00649                typename BasicImageView<PixelType>::Accessor>
    00650 destImageRange(BasicImageView<PixelType> & img, Rect2D const & roi)
    00651 {
    00652     vigra_precondition(roi.left() >= 0 && roi.top() >= 0 &&
    00653                        roi.right() <= img.width() && roi.bottom() <= img.height(),
    00654                        "destImageRange(): ROI rectangle outside image.");
    00655     return triple<typename BasicImageView<PixelType>::traverser,
    00656                   typename BasicImageView<PixelType>::traverser,
    00657                   typename BasicImageView<PixelType>::Accessor>(img.upperLeft() + roi.upperLeft(),
    00658                                                                    img.upperLeft() + roi.lowerRight(),
    00659                                                                    img.accessor());
    00660 }
    00661
    00662 template <class PixelType>
    00663 inline pair< typename BasicImageView<PixelType>::traverser,
    00664              typename BasicImageView<PixelType>::Accessor>
    00665 destImage(BasicImageView<PixelType> & img)
    00666 {
    00667     return pair<typename BasicImageView<PixelType>::traverser,
    00668                 typename BasicImageView<PixelType>::Accessor>(img.upperLeft(),
    00669                                                           img.accessor());
    00670 }
    00671
    00672 template <class PixelType>
    00673 inline pair< typename BasicImageView<PixelType>::traverser,
    00674              typename BasicImageView<PixelType>::Accessor>
    00675 destImage(BasicImageView<PixelType> & img, Point2D const & ul)
    00676 {
    00677     vigra_precondition(img.isInside(ul),
    00678                        "destImage(): ROI rectangle outside image.");
    00679     return pair<typename BasicImageView<PixelType>::traverser,
    00680                 typename BasicImageView<PixelType>::Accessor>(img.upperLeft() + ul,
    00681                                                                  img.accessor());
    00682 }
    00683
    00684 template <class PixelType>
    00685 inline pair< typename BasicImageView<PixelType>::const_traverser,
    00686              typename BasicImageView<PixelType>::ConstAccessor>
    00687 maskImage(BasicImageView<PixelType> const & img)
    00688 {
    00689     return pair<typename BasicImageView<PixelType>::const_traverser,
    00690                 typename BasicImageView<PixelType>::ConstAccessor>(img.upperLeft(),
    00691                                                                       img.accessor());
    00692 }
    00693
    00694 template <class PixelType>
    00695 inline pair< typename BasicImageView<PixelType>::const_traverser,
    00696              typename BasicImageView<PixelType>::ConstAccessor>
    00697 maskImage(BasicImageView<PixelType> const & img, Point2D const & ul)
    00698 {
    00699     vigra_precondition(img.isInside(ul),
    00700                        "maskImage(): ROI rectangle outside image.");
    00701     return pair<typename BasicImageView<PixelType>::const_traverser,
    00702                 typename BasicImageView<PixelType>::ConstAccessor>(img.upperLeft() + ul,
    00703                                                                       img.accessor());
    00704 }
    00705
    00706 } // namespace vigra
    00707 #undef VIGRA_ASSERT_INSIDE
    00708 #endif /* VIGRA_BASICIMAGEVIEW_HXX */

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.7.1 (3 Dec 2010)