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

# vigra/basicimageview.hxx

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