#include <iter.hh>
Inheritance diagram for oln::abstract::iter< Exact >:
Public Types | |
typedef iter_traits< Exact >::point_type | point_type |
The associate image's type of point. | |
typedef iter_traits< Exact >::dpoint_type | dpoint_type |
The associate image's type of dpoint (move point). | |
Public Member Functions | |
const point_type & | point_ref () const |
Accessor to current iterator's point. | |
bool | operator== (const abstract::point< point_type > &p) const |
Compare with the current iterator's point. | |
bool | operator!= (const abstract::point< point_type > &p) const |
Compare with the current iterator's point. | |
point_type | operator+ (const abstract::dpoint< dpoint_type > &dp) const |
Sum a move point to the current point. | |
point_type | operator- (const abstract::dpoint< dpoint_type > &dp) const |
Minor a move to the current point. | |
operator point_type () const | |
Cast to exact point type. | |
point_type | cur () const |
Syntax improvement. | |
mlc::begin_type | operator= (mlc::begin_type b) |
Set current point to the first iterator's point. | |
mlc::end_type | operator= (mlc::end_type e) |
Set current point to the last iterator's point. | |
bool | operator== (mlc::end_type) const |
Compare current point and last point. | |
void | operator++ () |
Go to the next iterator's point. | |
bool | operator!= (mlc::end_type e) const |
Compare current point and last point. | |
Static Public Member Functions | |
static std::string | name () |
Return the name of the type. | |
Protected Member Functions | |
iter () | |
Constructor. | |
Protected Attributes | |
point_type | p_ |
The iterator's current point. |
Allow iterable object (like image, window, ...) traversing.
#include <oln/basics2d.hh> #include <ntg/all.hh> #include <iostream> #include <assert.h> using namespace oln; using namespace ntg; int main(int argc, char **argv) { image2d<bin> image1 = load(IMG_IN "se.pbm"); assert(image1.has_impl()); oln_iter_type_(image2d<bin>) i(image1); for_all(i) { std::cout << image1[i] << std::endl; } }
This code is equivalent to the previous one but DEPRECATED (prefer to use the for_all macro):
#include <oln/basics2d.hh> #include <ntg/all.hh> #include <iostream> #include <assert.h> using namespace oln; using namespace ntg; int main(int argc, char **argv) { image2d<bin> image1 = load(IMG_IN "se.pbm"); assert(image1.has_impl()); for (int row = 0; row < image1.nrows(); ++row) for (int col = 0; col < image1.ncols(); ++col) std::cout << image1(row, col) << std::endl; }
You can use the same iterator on several image if they have the same size.
#include <oln/basics2d.hh> #include <ntg/all.hh> #include <iostream> #include <assert.h> using namespace oln; using namespace ntg; int main(int argc, char **argv) { image2d<bin> image1 = load(IMG_IN "se.pbm"); image2d<bin> image2 = load(IMG_IN "se.pbm"); assert(image1.has_impl()); assert(image2.has_impl()); oln_iter_type_(image2d<bin>) i(image1); for_all(i) { std::cout << "image1:" << image1[i] << std::endl; std::cout << "image2:" << image2[i] << std::endl; } return 0; }
You can iterate not only image but windows. This example make a binary dilatation to show you how to use them:
#include <oln/basics2d.hh> #include <ntg/all.hh> #include <iostream> #include <assert.h> using namespace oln; using namespace ntg; int main(int argc, char **argv) { image2d<bin> image1 = load(IMG_IN "object.pbm"); assert(image1.has_impl()); image2d<bin> image1_out(image1.size()); oln_iter_type_(image2d<bin>) i(image1); for_all(i) { image1_out[i] = image1[i]; if (!image1[i]) { window2d win = win_c8_only(); oln_iter_type_(window2d) j(win); bool change_color = false; for_all(j) { if (image1[i + j]) change_color = true; } image1_out[i] = change_color; } } save(image1_out, IMG_OUT "oln_abstract_iter.pbm"); return 0; }
Definition at line 179 of file iter.hh.
typedef iter_traits<Exact>::point_type oln::abstract::iter< Exact >::point_type |
The associate image's type of point.
Reimplemented in oln::bkd_iter1d< Exact >, oln::bkd_iter2d< Exact >, oln::bkd_iter3d< Exact >, oln::fwd_iter1d< Exact >, oln::fwd_iter2d< Exact >, and oln::fwd_iter3d< Exact >.
typedef iter_traits<Exact>::dpoint_type oln::abstract::iter< Exact >::dpoint_type |
oln::abstract::iter< Exact >::iter | ( | ) | [inline, protected] |
const point_type& oln::abstract::iter< Exact >::point_ref | ( | ) | const [inline] |
bool oln::abstract::iter< Exact >::operator== | ( | const abstract::point< point_type > & | p | ) | const [inline] |
Compare with the current iterator's point.
Definition at line 214 of file iter.hh.
Referenced by oln::abstract::iter< mlc::exact_vt< oln::fwd_iter1d< Exact >, Exact >::ret >::operator!=().
00215 { 00216 return p_ == p.exact(); 00217 }
bool oln::abstract::iter< Exact >::operator!= | ( | const abstract::point< point_type > & | p | ) | const [inline] |
point_type oln::abstract::iter< Exact >::operator+ | ( | const abstract::dpoint< dpoint_type > & | dp | ) | const [inline] |
point_type oln::abstract::iter< Exact >::operator- | ( | const abstract::dpoint< dpoint_type > & | dp | ) | const [inline] |
oln::abstract::iter< Exact >::operator point_type | ( | ) | const [inline] |
point_type oln::abstract::iter< Exact >::cur | ( | ) | const [inline] |
mlc::begin_type oln::abstract::iter< Exact >::operator= | ( | mlc::begin_type | b | ) | [inline] |
Set current point to the first iterator's point.
Set current point of iterator to the first iterator's point.
Definition at line 298 of file iter.hh.
Referenced by oln::fwd_iter3d< Exact >::operator=(), oln::fwd_iter2d< Exact >::operator=(), oln::fwd_iter1d< Exact >::operator=(), oln::bkd_iter3d< Exact >::operator=(), oln::bkd_iter2d< Exact >::operator=(), and oln::bkd_iter1d< Exact >::operator=().
00299 { 00300 this->exact().goto_begin_(); 00301 return b; 00302 }
mlc::end_type oln::abstract::iter< Exact >::operator= | ( | mlc::end_type | e | ) | [inline] |
bool oln::abstract::iter< Exact >::operator== | ( | mlc::end_type | ) | const [inline] |
void oln::abstract::iter< Exact >::operator++ | ( | ) | [inline] |
bool oln::abstract::iter< Exact >::operator!= | ( | mlc::end_type | e | ) | const [inline] |
Compare current point and last point.
Definition at line 356 of file iter.hh.
00357 { 00358 return ! this->operator==(e); 00359 }