#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 | |
| 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.
|
|||||
|
The associate image's type of dpoint (move point).
|
|
|||||
|
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 >. |
|
|||||||||
|
Constructor. Do nothing, used only by sub-classes Definition at line 377 of file iter.hh.
00378 {}
|
|
|||||||||
|
Syntax improvement. It's convenient to type `it.cur()' instead of `(point)it' when necessary. Definition at line 280 of file iter.hh.
00281 {
00282 return *this;
00283 }
|
|
|||||||||
|
Cast to exact point type.
Definition at line 268 of file iter.hh.
00269 {
00270 return this->exact().to_point();
00271 }
|
|
||||||||||
|
Compare current point and last point.
Definition at line 356 of file iter.hh.
00357 {
00358 return ! this->operator==(e);
00359 }
|
|
||||||||||
|
Compare with the current iterator's point.
Compare the current iterator's point with p (his argument). If they are different, return true. Definition at line 227 of file iter.hh.
00228 {
00229 return p_ != p.exact();
00230 }
|
|
||||||||||
|
Sum a move point to the current point.
Definition at line 241 of file iter.hh.
00242 {
00243 precondition(*this != end);
00244 return p_ + dp.exact();
00245 }
|
|
|||||||||
|
Go to the next iterator's point.
Definition at line 333 of file iter.hh.
00334 {
00335 precondition(*this != end);
00336 this->exact().goto_next_();
00337 }
|
|
||||||||||
|
Minor a move to the current point.
Definition at line 256 of file iter.hh.
00257 {
00258 precondition(*this != end);
00259 return p_ - dp.exact();
00260 }
|
|
||||||||||
|
Set current point to the last iterator's point. Set current point of iterator to the last iterator's point. Definition at line 310 of file iter.hh.
00311 {
00312 this->exact().goto_end_();
00313 return e;
00314 }
|
|
||||||||||
|
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.
00299 {
00300 this->exact().goto_begin_();
00301 return b;
00302 }
|
|
||||||||||
|
Compare current point and last point.
Definition at line 323 of file iter.hh.
00324 {
00325 return this->exact().is_at_end_();
00326 }
|
|
||||||||||
|
Compare with the current iterator's point.
Compare the current iterator's point with p (his argument). If successful, return true. Definition at line 214 of file iter.hh. Referenced by oln::abstract::iter< mlc::exact_vt< bkd_iter2d< Exact >, Exact >::ret >::operator!=().
00215 {
00216 return p_ == p.exact();
00217 }
|
|
|||||||||
|
Accessor to current iterator's point. Just return the current point of the iterator which is traversing an image. Definition at line 201 of file iter.hh.
00202 {
00203 return p_;
00204 }
|
1.3.6-20040222