SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GrayscaleImage.hpp
Go to the documentation of this file.
1 /*
2  * Copyright(c):
3  * Signal Image and Communications (SIC) Department
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * - University of Poitiers, France http://www.univ-poitiers.fr
6  * - XLIM Institute UMR CNRS 7252 http://www.xlim.fr/
7  *
8  * and
9  *
10  * D2 Fluid, Thermic and Combustion
11  * - University of Poitiers, France http://www.univ-poitiers.fr
12  * - PPRIME Institute - UPR CNRS 3346 http://www.pprime.fr
13  * - ISAE-ENSMA http://www.ensma.fr
14  *
15  * Contributor(s):
16  * The SLIP team,
17  * Benoit Tremblais <tremblais_AT_sic.univ-poitiers.fr>,
18  * Laurent David <laurent.david_AT_lea.univ-poitiers.fr>,
19  * Ludovic Chatellier <ludovic.chatellier_AT_univ-poitiers.fr>,
20  * Lionel Thomas <lionel.thomas_AT_univ-poitiers.fr>,
21  * Denis Arrivault <arrivault_AT_sic.univ-poitiers.fr>,
22  * Julien Dombre <julien.dombre_AT_univ-poitiers.fr>.
23  *
24  * Description:
25  * The Simple Library of Image Processing (SLIP) is a new image processing
26  * library. It is written in the C++ language following as much as possible
27  * the ISO/ANSI C++ standard. It is consequently compatible with any system
28  * satisfying the ANSI C++ complience. It works on different Unix , Linux ,
29  * Mircrosoft Windows and Mac OS X plateforms. SLIP is a research library that
30  * was created by the Signal, Image and Communications (SIC) departement of
31  * the XLIM, UMR 7252 CNRS Institute in collaboration with the Fluids, Thermic
32  * and Combustion departement of the P', UPR 3346 CNRS Institute of the
33  * University of Poitiers.
34  *
35  * The SLIP Library source code has been registered to the APP (French Agency
36  * for the Protection of Programs) by the University of Poitiers and CNRS,
37  * under registration number IDDN.FR.001.300034.000.S.P.2010.000.21000.
38 
39  * http://www.sic.sp2mi.univ-poitiers.fr/slip/
40  *
41  * This software is governed by the CeCILL-C license under French law and
42  * abiding by the rules of distribution of free software. You can use,
43  * modify and/ or redistribute the software under the terms of the CeCILL-C
44  * license as circulated by CEA, CNRS and INRIA at the following URL
45  * http://www.cecill.info.
46  * As a counterpart to the access to the source code and rights to copy,
47  * modify and redistribute granted by the license, users are provided only
48  * with a limited warranty and the software's author, the holder of the
49  * economic rights, and the successive licensors have only limited
50  * liability.
51  *
52  * In this respect, the user's attention is drawn to the risks associated
53  * with loading, using, modifying and/or developing or reproducing the
54  * software by the user in light of its specific status of free software,
55  * that may mean that it is complicated to manipulate, and that also
56  * therefore means that it is reserved for developers and experienced
57  * professionals having in-depth computer knowledge. Users are therefore
58  * encouraged to load and test the software's suitability as regards their
59  * requirements in conditions enabling the security of their systems and/or
60  * data to be ensured and, more generally, to use and operate it in the
61  * same conditions as regards security.
62  *
63  * The fact that you are presently reading this means that you have had
64  * knowledge of the CeCILL-C license and that you accept its terms.
65  */
66 
67 
68 
75 #ifndef SLIP_GRAYSCALEIMAGE_HPP
76 #define SLIP_GRAYSCALEIMAGE_HPP
77 
78 #include <iostream>
79 #include <iterator>
80 #include <cassert>
81 #include <numeric>
82 #include <cmath>
83 #include <string>
84 #include <cstddef>
85 //read/write image with ImageMagick
86 //breaking the ImageMagick dependency possibility
87 // Author : denis.arrivault\AT\inria.fr
88 // Date : 2013/04/05
89 // \since 1.4.0
90 #ifdef HAVE_MAGICK
91 #include <wand/magick_wand.h>
92 #include <magick/api.h>
93 #endif
94 #include "Matrix.hpp"
95 #include "stride_iterator.hpp"
96 #include "iterator2d_box.hpp"
97 #include "iterator2d_range.hpp"
98 #include "apply.hpp"
99 #include "io_tools.hpp"
100 
101 #include <boost/serialization/access.hpp>
102 #include <boost/serialization/split_member.hpp>
103 #include <boost/serialization/version.hpp>
104 
105 namespace slip
106 {
107 
108 template<class T>
109 class stride_iterator;
110 
111 template<class T>
112 class iterator2d_box;
113 
114 
115 template<class T>
116 class const_iterator2d_box;
117 
118 template<class T>
119 class const_iterator2d_range;
120 
121 template <class T>
122 class DPoint2d;
123 
124 template <class T>
125 class Point2d;
126 
127 template <class T>
128 class Box2d;
129 
130 template <class T>
131 class Range;
132 
133 template <typename T>
135 
136 template <typename T>
137 class Matrix;
138 
139 template <typename T>
140 std::ostream& operator<<(std::ostream & out, const slip::GrayscaleImage<T>& a);
141 
142 template<typename T>
143 bool operator==(const slip::GrayscaleImage<T>& x,
144  const slip::GrayscaleImage<T>& y);
145 
146 template<typename T>
147 bool operator!=(const slip::GrayscaleImage<T>& x,
148  const slip::GrayscaleImage<T>& y);
149 
150 template<typename T>
151 bool operator<(const slip::GrayscaleImage<T>& x,
152  const slip::GrayscaleImage<T>& y);
153 
154 template<typename T>
155 bool operator>(const slip::GrayscaleImage<T>& x,
156  const slip::GrayscaleImage<T>& y);
157 
158 template<typename T>
159 bool operator<=(const slip::GrayscaleImage<T>& x,
160  const slip::GrayscaleImage<T>& y);
161 
162 template<typename T>
163 bool operator>=(const slip::GrayscaleImage<T>& x,
164  const slip::GrayscaleImage<T>& y);
165 
188 template <typename T>
189 class GrayscaleImage
190 {
191 public :
192 
193  typedef T value_type;
194  typedef GrayscaleImage<T> self;
196 
197  typedef value_type* pointer;
198  typedef const value_type* const_pointer;
200  typedef const value_type& const_reference;
201 
202  typedef ptrdiff_t difference_type;
203  typedef std::size_t size_type;
204 
205  typedef pointer iterator;
207 
208  typedef std::reverse_iterator<iterator> reverse_iterator;
209  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
210 
211 
216 
217 
226 
227 
228  typedef std::reverse_iterator<iterator> reverse_row_iterator;
229  typedef std::reverse_iterator<const_iterator> const_reverse_row_iterator;
230  typedef std::reverse_iterator<col_iterator> reverse_col_iterator;
231  typedef std::reverse_iterator<const_col_iterator> const_reverse_col_iterator;
232  typedef std::reverse_iterator<iterator2d> reverse_iterator2d;
233  typedef std::reverse_iterator<const_iterator2d> const_reverse_iterator2d;
234  typedef std::reverse_iterator<row_range_iterator> reverse_row_range_iterator;
235  typedef std::reverse_iterator<const_row_range_iterator> const_reverse_row_range_iterator;
236  typedef std::reverse_iterator<col_range_iterator> reverse_col_range_iterator;
237  typedef std::reverse_iterator<const_col_range_iterator> const_reverse_col_range_iterator;
238  typedef std::reverse_iterator<iterator2d_range> reverse_iterator2d_range;
239  typedef std::reverse_iterator<const_iterator2d_range> const_reverse_iterator2d_range;
240 
241  //default iterator of the container
244 
245  static const std::size_t DIM = 2;
246 
247 public:
252 
256  GrayscaleImage();
257 
264  const size_type width);
265 
273  const size_type width,
274  const T& val);
275 
283  const size_type width,
284  const T* val);
285 
286 
297  template<typename InputIterator>
299  const size_type width,
300  InputIterator first,
301  InputIterator last)
302  {
303  matrix_ = new slip::Matrix<T>(height,width,first,last);
304  }
305 
309  GrayscaleImage(const self& rhs);
310 
314  ~GrayscaleImage();
315 
316 
326  void resize(const size_type height,
327  const size_type width,
328  const T& val = T());
329 
330 
331 
332 
337 
357  iterator begin();
358 
359 
379  iterator end();
380 
401  const_iterator begin() const;
402 
403 
423  const_iterator end() const;
424 
446 
468 
490 
491 
513 
514 
534  row_iterator row_begin(const size_type row);
535 
536 
556  row_iterator row_end(const size_type row);
557 
558 
578  const_row_iterator row_begin(const size_type row) const;
579 
580 
600  const_row_iterator row_end(const size_type row) const;
601 
621  col_iterator col_begin(const size_type col);
622 
623 
643  col_iterator col_end(const size_type col);
644 
664  const_col_iterator col_begin(const size_type col) const;
665 
666 
667 
687  const_col_iterator col_end(const size_type col) const;
688 
689 
715  const slip::Range<int>& range);
716 
717 
718 
744  const slip::Range<int>& range);
745 
746 
772  const slip::Range<int>& range) const;
773 
774 
799  const slip::Range<int>& range) const;
800 
801 
827  const slip::Range<int>& range);
828 
855  const slip::Range<int>& range);
856 
857 
858 
859 
885  const slip::Range<int>& range) const;
886 
887 
914  const slip::Range<int>& range) const;
915 
916 
917 
930 
931 
944 
957 
970 
984 
985 
999 
1013 
1014 
1028 
1029 
1045  const slip::Range<int>& range);
1046 
1047 
1064  const slip::Range<int>& range);
1065 
1066 
1067 
1081  const slip::Range<int>& range) const;
1082 
1083 
1099  const slip::Range<int>& range) const;
1100 
1101 
1102 
1103 
1119  const slip::Range<int>& range);
1120 
1137  const slip::Range<int>& range);
1138 
1139 
1155  col_rbegin(const size_type col,
1156  const slip::Range<int>& range) const;
1157 
1158 
1174  const slip::Range<int>& range) const;
1175 
1176 
1195 
1196 
1215 
1216 
1234  const_iterator2d upper_left() const;
1235 
1236 
1255 
1279  iterator2d upper_left(const Box2d<int>& box);
1280 
1281 
1306  iterator2d bottom_right(const Box2d<int>& box);
1307 
1308 
1333  const_iterator2d upper_left(const Box2d<int>& box) const;
1334 
1335 
1360  const_iterator2d bottom_right(const Box2d<int>& box) const;
1361 
1362 
1390  iterator2d_range upper_left(const Range<int>& row_range,
1391  const Range<int>& col_range);
1392 
1420  iterator2d_range bottom_right(const Range<int>& row_range,
1421  const Range<int>& col_range);
1422 
1423 
1451  const_iterator2d_range upper_left(const Range<int>& row_range,
1452  const Range<int>& col_range) const;
1453 
1454 
1483  const Range<int>& col_range) const;
1484 
1485 
1486 
1487 
1488 
1513  iterator2d_range upper_left(const Range<int>& range);
1514 
1515 
1542 
1543 
1544 
1545 
1570  const_iterator2d_range upper_left(const Range<int>& range) const;
1571 
1572 
1573 
1599  const_iterator2d_range bottom_right(const Range<int>& range) const;
1600 
1601 
1612 
1623 
1634 
1635 
1646 
1647 
1663 
1679 
1695 
1696 
1712 
1713 
1731  const Range<int>& col_range);
1732 
1733 
1734 
1752  const Range<int>& col_range);
1753 
1754 
1755 
1773  const Range<int>& col_range) const;
1774 
1792  const Range<int>& col_range) const;
1793 
1794 
1795 
1812 
1813 
1814 
1832 
1833 
1851 
1852 
1870 
1871 
1878 
1884  friend std::ostream& operator<< <>(std::ostream & out, const self& a);
1885 
1886  #ifdef HAVE_MAGICK
1887 
1895  void read(const std::string& file_path_name);
1896 
1905  void write(const std::string& file_path_name) const;
1906 #endif
1907 
1912  void write_ascii(const std::string& file_path_name) const
1913  {
1914  slip::write_ascii_2d<self,value_type>(*this,file_path_name);
1915  }
1916 
1922  void read_ascii(const std::string& file_path_name)
1923  {
1924  slip::read_ascii_2d<self>(*this,file_path_name);
1925  }
1932 
1941  GrayscaleImage& operator=(const self & rhs);
1942 
1948  self& operator=(const T& val);
1949 
1950 
1951 
1957  void fill(const T& value)
1958  {
1959  std::fill_n(this->begin(),size(),value);
1960  }
1961 
1968  void fill(const T* value)
1969  {
1970  std::copy(value,value + size(),this->begin());
1971  }
1972 
1981  template<typename InputIterator>
1982  void fill(InputIterator first,
1983  InputIterator last)
1984  {
1985  std::copy(first,last,this->begin());
1986  }
2000  friend bool operator== <>(const GrayscaleImage<T>& x,
2001  const GrayscaleImage<T>& y);
2002 
2010  friend bool operator!= <>(const GrayscaleImage<T>& x,
2011  const GrayscaleImage<T>& y);
2012 
2020  friend bool operator< <>(const GrayscaleImage<T>& x,
2021  const GrayscaleImage<T>& y);
2022 
2030  friend bool operator> <>(const GrayscaleImage<T>& x,
2031  const GrayscaleImage<T>& y);
2032 
2040  friend bool operator<= <>(const GrayscaleImage<T>& x,
2041  const GrayscaleImage<T>& y);
2042 
2050  friend bool operator>= <>(const GrayscaleImage<T>& x,
2051  const GrayscaleImage<T>& y);
2052 
2053 
2070  pointer operator[](const size_type i);
2071 
2082  const_pointer operator[](const size_type i) const;
2083 
2084 
2097  reference operator()(const size_type i,
2098  const size_type j);
2099 
2113  const size_type j) const;
2114 
2126  reference operator()(const Point2d<size_type>& point2d);
2127 
2139  const_reference operator()(const Point2d<size_type>& point2d) const;
2140 
2141 
2154  self operator()(const Range<int>& row_range,
2155  const Range<int>& col_range);
2156 
2163  std::string name() const;
2164 
2169  size_type dim1() const;
2170 
2175  size_type rows() const;
2176 
2181  size_type height() const;
2182 
2187  size_type dim2() const;
2188 
2193  size_type columns() const;
2194 
2199  size_type cols() const;
2200 
2205  size_type width() const;
2206 
2210  size_type size() const;
2211 
2215  size_type max_size() const;
2216 
2220  bool empty()const;
2221 
2226  void swap(self& M);
2227 
2237  self& operator+=(const T& val);
2238  self& operator-=(const T& val);
2239  self& operator*=(const T& val);
2240  self& operator/=(const T& val);
2241 // self& operator%=(const T& val);
2242 // self& operator^=(const T& val);
2243 // self& operator&=(const T& val);
2244 // self& operator|=(const T& val);
2245 // self& operator<<=(const T& val);
2246 // self& operator>>=(const T& val);
2247 
2248 
2249  self operator-() const;
2250  //self operator!() const;
2251 
2252 
2253 
2254  self& operator+=(const self& rhs);
2255  self& operator-=(const self& rhs);
2256  self& operator*=(const self& rhs);
2257  self& operator/=(const self& rhs);
2258 
2259 
2268  T& min() const;
2269 
2270 
2276  T& max() const;
2277 
2282  T sum() const;
2283 
2299  GrayscaleImage<T>& apply(T (*fun)(T));
2300 
2316  GrayscaleImage<T>& apply(T (*fun)(const T&));
2317 
2318 
2319  private:
2320  slip::Matrix<T>* matrix_;
2321 
2322  private:
2324  template<class Archive>
2325  void save(Archive & ar, const unsigned int version) const
2326  {
2327  ar & this->matrix_;
2328  }
2329  template<class Archive>
2330  void load(Archive & ar, const unsigned int version)
2331  {
2332  ar & this->matrix_;
2333  }
2334  BOOST_SERIALIZATION_SPLIT_MEMBER();
2335 };
2336 
2357 
2358 
2359 }//slip::
2360 
2361 namespace slip{
2370 template<typename T>
2371 GrayscaleImage<T> operator+(const GrayscaleImage<T>& M1,
2372  const GrayscaleImage<T>& M2);
2373 
2380 template<typename T>
2381 GrayscaleImage<T> operator+(const GrayscaleImage<T>& M1,
2382  const T& val);
2383 
2390  template<typename T>
2391  GrayscaleImage<T> operator+(const T& val,
2392  const GrayscaleImage<T>& M1);
2393 
2402 template<typename T>
2403 GrayscaleImage<T> operator-(const GrayscaleImage<T>& M1,
2404  const GrayscaleImage<T>& M2);
2405 
2412 template<typename T>
2413 GrayscaleImage<T> operator-(const GrayscaleImage<T>& M1,
2414  const T& val);
2415 
2422  template<typename T>
2423  GrayscaleImage<T> operator-(const T& val,
2424  const GrayscaleImage<T>& M1);
2425 
2434  template<typename T>
2435  GrayscaleImage<T> operator*(const GrayscaleImage<T>& M1,
2436  const GrayscaleImage<T>& M2);
2437 
2444  template<typename T>
2445  GrayscaleImage<T> operator*(const GrayscaleImage<T>& M1,
2446  const T& val);
2447 
2454  template<typename T>
2455  GrayscaleImage<T> operator*(const T& val,
2456  const GrayscaleImage<T>& M1);
2457 
2466  template<typename T>
2467  GrayscaleImage<T> operator/(const GrayscaleImage<T>& M1,
2468  const GrayscaleImage<T>& M2);
2469 
2476  template<typename T>
2477  GrayscaleImage<T> operator/(const GrayscaleImage<T>& M1,
2478  const T& val);
2479 
2480 
2481 
2488  template<typename T>
2489  T& min(const GrayscaleImage<T>& M1);
2490 
2497  template<typename T>
2498  T& max(const GrayscaleImage<T>& M1);
2499 
2500 }//slip::
2501 
2502 namespace slip
2503 {
2504  template<typename T>
2505  inline
2507  matrix_(new slip::Matrix<T>())
2508  {}
2509 
2510  template<typename T>
2511  inline
2513  const typename GrayscaleImage<T>::size_type width):
2514  matrix_(new slip::Matrix<T>(height,width))
2515  {}
2516 
2517  template<typename T>
2518  inline
2520  const typename GrayscaleImage<T>::size_type width,
2521  const T& val):
2522  matrix_(new slip::Matrix<T>(height,width,val))
2523  {}
2524 
2525  template<typename T>
2526  inline
2528  const typename GrayscaleImage<T>::size_type width,
2529  const T* val):
2530  matrix_(new slip::Matrix<T>(height,width,val))
2531  {}
2532 
2533  template<typename T>
2534  inline
2536  matrix_(new slip::Matrix<T>((*rhs.matrix_)))
2537  {}
2538 
2539  template<typename T>
2540  inline
2542  {
2543  delete matrix_;
2544  }
2545 
2546  template<typename T>
2547  inline
2549  {
2550  if(this != &rhs)
2551  {
2552  *matrix_ = *(rhs.matrix_);
2553  }
2554  return *this;
2555  }
2556 
2557  template<typename T>
2558  inline
2560  {
2561  std::fill_n(matrix_->begin(),matrix_->size(),val);
2562  return *this;
2563  }
2564 
2565  template<typename T>
2566  inline
2568  const typename GrayscaleImage<T>::size_type width,
2569  const T& val)
2570  {
2571  matrix_->resize(height,width,val);
2572  }
2573 
2574 
2575  template<typename T>
2576  inline
2578  {
2579  return matrix_->begin();
2580  }
2581 
2582  template<typename T>
2583  inline
2585  {
2586  return matrix_->end();
2587  }
2588 
2589  template<typename T>
2590  inline
2592  {
2593  slip::Matrix<T> const * tp(matrix_);
2594  return tp->begin();
2595  }
2596 
2597  template<typename T>
2598  inline
2600  {
2601  slip::Matrix<T> const * tp(matrix_);
2602  return tp->end();
2603  }
2604 
2605 
2606  template<typename T>
2607  inline
2609  {
2610  return typename GrayscaleImage<T>::reverse_iterator(this->end());
2611  }
2612 
2613  template<typename T>
2614  inline
2616  {
2617  return typename GrayscaleImage<T>::reverse_iterator(this->begin());
2618  }
2619 
2620  template<typename T>
2621  inline
2624  {
2625  return typename GrayscaleImage<T>::const_reverse_iterator(this->end());
2626  }
2627 
2628  template<typename T>
2629  inline
2630  std::reverse_iterator<const T*>
2632  {
2633  return std::reverse_iterator<const T*>(begin());
2634  }
2635 
2636  template<typename T>
2637  inline
2640  {
2641  return matrix_->row_begin(row);
2642  }
2643 
2644  template<typename T>
2645  inline
2646  typename GrayscaleImage<T>::row_iterator
2647  GrayscaleImage<T>::row_end(const typename GrayscaleImage<T>::size_type row)
2648  {
2649  return matrix_->row_end(row);
2650  }
2651 
2652  template<typename T>
2653  inline
2654  typename GrayscaleImage<T>::col_iterator
2655  GrayscaleImage<T>::col_begin(const typename GrayscaleImage<T>::size_type col)
2656  {
2657  return matrix_->col_begin(col);
2658  }
2659 
2660 
2661  template<typename T>
2662  inline
2663  typename GrayscaleImage<T>::col_iterator
2664  GrayscaleImage<T>::col_end(const typename GrayscaleImage<T>::size_type col)
2665  {
2666  return matrix_->col_end(col);
2667  }
2668 
2669 
2670  template<typename T>
2671  inline
2672  typename GrayscaleImage<T>::const_row_iterator
2673  GrayscaleImage<T>::row_begin(const typename GrayscaleImage<T>::size_type row) const
2674  {
2675  slip::Matrix<T> const * tp(matrix_);
2676  return tp->row_begin(row);
2677  }
2678 
2679  template<typename T>
2680  inline
2681  typename GrayscaleImage<T>::const_row_iterator
2682  GrayscaleImage<T>::row_end(const typename GrayscaleImage<T>::size_type row) const
2683  {
2684  slip::Matrix<T> const * tp(matrix_);
2685  return tp->row_end(row);
2686  }
2687 
2688  template<typename T>
2689  inline
2690  typename GrayscaleImage<T>::const_col_iterator
2691  GrayscaleImage<T>::col_begin(const typename GrayscaleImage<T>::size_type col) const
2692  {
2693  slip::Matrix<T> const * tp(matrix_);
2694  return tp->col_begin(col);
2695  }
2696 
2697  template<typename T>
2698  inline
2699  typename GrayscaleImage<T>::const_col_iterator
2700  GrayscaleImage<T>::col_end(const typename GrayscaleImage<T>::size_type col) const
2701  {
2702  slip::Matrix<T> const * tp(matrix_);
2703  return tp->col_end(col);
2704  }
2705 
2706 
2707  //
2708  template<typename T>
2709  inline
2710  typename GrayscaleImage<T>::reverse_row_iterator
2711  GrayscaleImage<T>::row_rbegin(const typename GrayscaleImage<T>::size_type row)
2712  {
2713  return matrix_->row_rbegin(row);
2714  }
2715 
2716  template<typename T>
2717  inline
2718  typename GrayscaleImage<T>::const_reverse_row_iterator
2719  GrayscaleImage<T>::row_rbegin(const typename GrayscaleImage<T>::size_type row) const
2720  {
2721  slip::Matrix<T> const * tp(matrix_);
2722  return tp->row_rbegin(row);
2723  }
2724 
2725  template<typename T>
2726  inline
2727  typename GrayscaleImage<T>::reverse_row_iterator
2728  GrayscaleImage<T>::row_rend(const typename GrayscaleImage<T>::size_type row)
2729  {
2730  return matrix_->row_rend(row);
2731  }
2732 
2733  template<typename T>
2734  inline
2735  typename GrayscaleImage<T>::const_reverse_row_iterator
2736  GrayscaleImage<T>::row_rend(const typename GrayscaleImage<T>::size_type row) const
2737  {
2738  slip::Matrix<T> const * tp(matrix_);
2739  return tp->row_rend(row);
2740  }
2741 
2742  template<typename T>
2743  inline
2744  typename GrayscaleImage<T>::reverse_col_iterator
2745  GrayscaleImage<T>::col_rbegin(const typename GrayscaleImage<T>::size_type col)
2746  {
2747  return matrix_->col_rbegin(col);
2748  }
2749 
2750  template<typename T>
2751  inline
2752  typename GrayscaleImage<T>::const_reverse_col_iterator GrayscaleImage<T>::col_rbegin(const typename GrayscaleImage<T>::size_type col) const
2753  {
2754  slip::Matrix<T> const * tp(matrix_);
2755  return tp->col_rbegin(col);
2756  }
2757 
2758  template<typename T>
2759  inline
2760  typename GrayscaleImage<T>::reverse_col_iterator
2761  GrayscaleImage<T>::col_rend(const typename GrayscaleImage<T>::size_type col)
2762  {
2763  return matrix_->col_rend(col);
2764  }
2765 
2766  template<typename T>
2767  inline
2768  typename GrayscaleImage<T>::const_reverse_col_iterator
2769  GrayscaleImage<T>::col_rend(const typename GrayscaleImage<T>::size_type col) const
2770  {
2771  slip::Matrix<T> const * tp(matrix_);
2772  return tp->col_rend(col);
2773  }
2774 
2775  template<typename T>
2776  inline
2777  typename GrayscaleImage<T>::row_range_iterator
2778  GrayscaleImage<T>::row_begin(const typename GrayscaleImage<T>::size_type row,
2779  const slip::Range<int>& range)
2780  {
2781  return matrix_->row_begin(row,range);
2782  }
2783 
2784  template<typename T>
2785  inline
2786  typename GrayscaleImage<T>::const_row_range_iterator
2787  GrayscaleImage<T>::row_begin(const typename GrayscaleImage<T>::size_type row,
2788  const slip::Range<int>& range) const
2789  {
2790  slip::Matrix<T> const * tp(matrix_);
2791  return tp->row_begin(row,range);
2792  }
2793 
2794  template<typename T>
2795  inline
2796  typename GrayscaleImage<T>::col_range_iterator
2797  GrayscaleImage<T>::col_begin(const typename GrayscaleImage<T>::size_type col,
2798  const slip::Range<int>& range)
2799  {
2800  return matrix_->col_begin(col,range);
2801  }
2802 
2803  template<typename T>
2804  inline
2805  typename GrayscaleImage<T>::const_col_range_iterator
2806  GrayscaleImage<T>::col_begin(const typename GrayscaleImage<T>::size_type col,
2807  const slip::Range<int>& range) const
2808  {
2809  slip::Matrix<T> const * tp(matrix_);
2810  return tp->col_begin(col,range);
2811  }
2812 
2813 
2814  template<typename T>
2815  inline
2816  typename GrayscaleImage<T>::row_range_iterator
2817  GrayscaleImage<T>::row_end(const typename GrayscaleImage<T>::size_type row,
2818  const slip::Range<int>& range)
2819  {
2820  return matrix_->row_end(row,range);
2821  }
2822 
2823  template<typename T>
2824  inline
2825  typename GrayscaleImage<T>::const_row_range_iterator
2826  GrayscaleImage<T>::row_end(const typename GrayscaleImage<T>::size_type row,
2827  const slip::Range<int>& range) const
2828  {
2829  slip::Matrix<T> const * tp(matrix_);
2830  return tp->row_end(row,range);
2831  }
2832 
2833  template<typename T>
2834  inline
2835  typename GrayscaleImage<T>::col_range_iterator
2836  GrayscaleImage<T>::col_end(const typename GrayscaleImage<T>::size_type col,
2837  const slip::Range<int>& range)
2838  {
2839  return matrix_->col_end(col,range);
2840  }
2841 
2842  template<typename T>
2843  inline
2844  typename GrayscaleImage<T>::const_col_range_iterator
2845  GrayscaleImage<T>::col_end(const typename GrayscaleImage<T>::size_type col,
2846  const slip::Range<int>& range) const
2847  {
2848  slip::Matrix<T> const * tp(matrix_);
2849  return tp->col_end(col,range);
2850  }
2851 
2852  template<typename T>
2853  inline
2854  typename GrayscaleImage<T>::reverse_row_range_iterator
2855  GrayscaleImage<T>::row_rbegin(const typename GrayscaleImage<T>::size_type row,
2856  const slip::Range<int>& range)
2857  {
2858  return typename GrayscaleImage<T>::reverse_row_range_iterator(this->row_end(row,range));
2859  }
2860 
2861  template<typename T>
2862  inline
2863  typename GrayscaleImage<T>::const_reverse_row_range_iterator
2864  GrayscaleImage<T>::row_rbegin(const typename GrayscaleImage<T>::size_type row,
2865  const slip::Range<int>& range) const
2866  {
2867  return typename GrayscaleImage<T>::const_reverse_row_range_iterator(this->row_end(row,range));
2868  }
2869 
2870 
2871  template<typename T>
2872  inline
2873  typename GrayscaleImage<T>::reverse_col_range_iterator
2874  GrayscaleImage<T>::col_rbegin(const typename GrayscaleImage<T>::size_type col,
2875  const slip::Range<int>& range)
2876  {
2877  return typename GrayscaleImage<T>::reverse_col_range_iterator(this->col_end(col,range));
2878  }
2879 
2880  template<typename T>
2881  inline
2882  typename GrayscaleImage<T>::const_reverse_col_range_iterator
2883  GrayscaleImage<T>::col_rbegin(const typename GrayscaleImage<T>::size_type col,
2884  const slip::Range<int>& range) const
2885  {
2886  return typename GrayscaleImage<T>::const_reverse_col_range_iterator(this->col_end(col,range));
2887  }
2888 
2889  template<typename T>
2890  inline
2891  typename GrayscaleImage<T>::reverse_row_range_iterator
2892  GrayscaleImage<T>::row_rend(const typename GrayscaleImage<T>::size_type row,
2893  const slip::Range<int>& range)
2894  {
2895  return typename GrayscaleImage<T>::reverse_row_range_iterator(this->row_begin(row,range));
2896  }
2897 
2898  template<typename T>
2899  inline
2900  typename GrayscaleImage<T>::const_reverse_row_range_iterator
2901  GrayscaleImage<T>::row_rend(const typename GrayscaleImage<T>::size_type row,
2902  const slip::Range<int>& range) const
2903  {
2904  return typename GrayscaleImage<T>::const_reverse_row_range_iterator(this->row_begin(row,range));
2905  }
2906 
2907 
2908  template<typename T>
2909  inline
2910  typename GrayscaleImage<T>::reverse_col_range_iterator
2911  GrayscaleImage<T>::col_rend(const typename GrayscaleImage<T>::size_type col,
2912  const slip::Range<int>& range)
2913  {
2914  return typename GrayscaleImage<T>::reverse_col_range_iterator(this->col_begin(col,range));
2915  }
2916 
2917  template<typename T>
2918  inline
2919  typename GrayscaleImage<T>::const_reverse_col_range_iterator
2920  GrayscaleImage<T>::col_rend(const typename GrayscaleImage<T>::size_type col,
2921  const slip::Range<int>& range) const
2922  {
2923  return typename GrayscaleImage<T>::const_reverse_col_range_iterator(this->col_begin(col,range));
2924  }
2925 
2926 
2927 
2928 
2929  template<typename T>
2930  inline
2932  {
2933  return matrix_->upper_left();
2934  }
2935 
2936  template<typename T>
2937  inline
2939  {
2940  slip::Matrix<T> const * tp(matrix_);
2941  return tp->upper_left();
2942  }
2943 
2944  template<typename T>
2945  inline
2947  {
2948  return matrix_->bottom_right();
2949  }
2950 
2951  template<typename T>
2952  inline
2954  {
2955  slip::Matrix<T> const * tp(matrix_);
2956  return tp->bottom_right();
2957  }
2958 
2959  template<typename T>
2960  inline
2963  {
2964  return matrix_->upper_left(box);
2965  }
2966 
2967 
2968  template<typename T>
2969  inline
2971  {
2972  slip::Matrix<T> const * tp(matrix_);
2973  return tp->upper_left(box);
2974  }
2975 
2976  template<typename T>
2977  inline
2980  {
2981  return matrix_->bottom_right(box);
2982  }
2983 
2984  template<typename T>
2985  inline
2987  {
2988  slip::Matrix<T> const * tp(matrix_);
2989  return tp->bottom_right(box);
2990  }
2991 
2992  template<typename T>
2993  inline
2996  const Range<int>& col_range)
2997  {
2998  return matrix_->upper_left(row_range,col_range);
2999  }
3000 
3001  template<typename T>
3002  inline
3005  const Range<int>& col_range) const
3006  {
3007  slip::Matrix<T> const * tp(matrix_);
3008  return tp->upper_left(row_range,col_range);
3009  }
3010 
3011  template<typename T>
3012  inline
3015  const Range<int>& col_range)
3016  {
3017  return matrix_->bottom_right(row_range,col_range);
3018  }
3019 
3020  template<typename T>
3021  inline
3024  const Range<int>& col_range) const
3025  {
3026  slip::Matrix<T> const * tp(matrix_);
3027  return tp->bottom_right(row_range,col_range);
3028  }
3029 
3030  template<typename T>
3031  inline
3034  {
3035  return matrix_->upper_left(range);
3036  }
3037 
3038  template<typename T>
3039  inline
3042  {
3043  slip::Matrix<T> const * tp(matrix_);
3044  return tp->upper_left(range);
3045  }
3046 
3047  template<typename T>
3048  inline
3051  {
3052  return matrix_->bottom_right(range);
3053  }
3054 
3055  template<typename T>
3056  inline
3059  {
3060  slip::Matrix<T> const * tp(matrix_);
3061  return tp->bottom_right(range);
3062  }
3063 
3064 
3065  template<typename T>
3066  inline
3069  {
3070  return matrix_->rbottom_right();
3071  }
3072 
3073  template<typename T>
3074  inline
3077  {
3078  slip::Matrix<T> const * tp(matrix_);
3079  return tp->rbottom_right();
3080  }
3081 
3082  template<typename T>
3083  inline
3086  {
3087  return matrix_->rupper_left();
3088  }
3089 
3090  template<typename T>
3091  inline
3094  {
3095  slip::Matrix<T> const * tp(matrix_);
3096  return tp->rupper_left();
3097  }
3098 
3099  template<typename T>
3100  inline
3103  {
3104  return matrix_->rbottom_right(box);
3105  }
3106 
3107  template<typename T>
3108  inline
3111  {
3112  slip::Matrix<T> const * tp(matrix_);
3113  return tp->rbottom_right(box);
3114  }
3115 
3116  template<typename T>
3117  inline
3120  {
3121  return matrix_->rupper_left(box);
3122  }
3123 
3124  template<typename T>
3125  inline
3128  {
3129  slip::Matrix<T> const * tp(matrix_);
3130  return tp->rupper_left(box);
3131  }
3132 
3133  template<typename T>
3134  inline
3137  const Range<int>& col_range)
3138  {
3139  return matrix_->rupper_left(row_range,col_range);
3140  }
3141 
3142  template<typename T>
3143  inline
3146  const Range<int>& col_range) const
3147  {
3148  slip::Matrix<T> const * tp(matrix_);
3149  return tp->rupper_left(row_range,col_range);
3150  }
3151 
3152  template<typename T>
3153  inline
3156  const Range<int>& col_range)
3157  {
3158  return matrix_->rbottom_right(row_range,col_range);
3159  }
3160 
3161  template<typename T>
3162  inline
3165  const Range<int>& col_range) const
3166  {
3167  slip::Matrix<T> const * tp(matrix_);
3168  return tp->rbottom_right(row_range,col_range);
3169  }
3170 
3171  template<typename T>
3172  inline
3175  {
3176  return this->rupper_left(range,range);
3177  }
3178 
3179  template<typename T>
3180  inline
3183  {
3184  return this->rupper_left(range,range);
3185  }
3186 
3187  template<typename T>
3188  inline
3191  {
3192  return this->rbottom_right(range,range);
3193  }
3194 
3195  template<typename T>
3196  inline
3199  {
3200  return this->rbottom_right(range,range);
3201  }
3202 
3203  template <typename T>
3204  inline
3205  std::ostream& operator<<(std::ostream & out,
3206  const GrayscaleImage<T>& a)
3207  {
3208  out<<*(a.matrix_)<<std::endl;
3209  return out;
3210  }
3211 
3213  #ifdef HAVE_MAGICK
3214  template<>
3215  inline
3216  void GrayscaleImage<unsigned char>::read(const std::string& file_path_name)
3217  {
3218  slip::read_magick_gray_char(file_path_name,*this);
3219  }
3220 
3221  template<>
3222  inline
3223  void GrayscaleImage<short>::read(const std::string& file_path_name)
3224  {
3225  slip::read_magick_gray_short(file_path_name,*this);
3226  }
3227 
3228  template<>
3229  inline
3230  void GrayscaleImage<int>::read(const std::string& file_path_name)
3231  {
3232  slip::read_magick_gray_int(file_path_name,*this);
3233  }
3234 
3235  template<>
3236  inline
3237  void GrayscaleImage<long>::read(const std::string& file_path_name)
3238  {
3239  slip::read_magick_gray_long(file_path_name,*this);
3240  }
3241 
3242  template<>
3243  inline
3244  void GrayscaleImage<float>::read(const std::string& file_path_name)
3245  {
3246  slip::read_magick_gray_float(file_path_name,*this);
3247  }
3248 
3249  template<>
3250  inline
3251  void GrayscaleImage<double>::read(const std::string& file_path_name)
3252  {
3253  slip::read_magick_gray_double(file_path_name,*this);
3254  }
3255 #endif
3256 
3258  template<>
3259  inline
3260  void GrayscaleImage<unsigned char>::write_ascii(const std::string& file_path_name) const
3261  {
3262  slip::write_ascii_2d<self,int>(*this,file_path_name);
3263  }
3264 #ifdef HAVE_MAGICK
3265  template<>
3266  inline
3267  void GrayscaleImage<unsigned char>::write(const std::string& file_path_name) const
3268  {
3269  slip::write_magick_gray_char(this->begin(),
3270  this->width(),this->height(),
3271  file_path_name);
3272  }
3273 
3274  template<>
3275  inline
3276  void GrayscaleImage<short>::write(const std::string& file_path_name) const
3277  {
3278  slip::write_magick_gray_short(this->begin(),
3279  this->width(),this->height(),
3280  file_path_name);
3281  }
3282 
3283  template<>
3284  inline
3285  void GrayscaleImage<int>::write(const std::string& file_path_name) const
3286  {
3287  slip::write_magick_gray_int(this->begin(),
3288  this->width(),this->height(),
3289  file_path_name);
3290  }
3291 
3292  template<>
3293  inline
3294  void GrayscaleImage<long>::write(const std::string& file_path_name) const
3295  {
3296  slip::write_magick_gray_long(this->begin(),
3297  this->width(),this->height(),
3298  file_path_name);
3299  }
3300 
3301  template<>
3302  inline
3303  void GrayscaleImage<float>::write(const std::string& file_path_name) const
3304  {
3305  slip::write_magick_gray_float(this->begin(),
3306  this->width(),this->height(),
3307  file_path_name);
3308  }
3309 
3310  template<>
3311  inline
3312  void GrayscaleImage<double>::write(const std::string& file_path_name) const
3313  {
3314  slip::write_magick_gray_double(this->begin(),
3315  this->width(),this->height(),
3316  file_path_name);
3317  }
3318 #endif
3319 
3321  template<typename T>
3322  inline
3323  typename GrayscaleImage<T>::pointer
3324  GrayscaleImage<T>::operator[](const typename GrayscaleImage<T>::size_type i)
3325  {
3326  return (*matrix_)[i];
3327  }
3328 
3329  template<typename T>
3330  inline
3331  typename GrayscaleImage<T>::const_pointer
3332  GrayscaleImage<T>::operator[](const typename GrayscaleImage<T>::size_type i) const
3333  {
3334  return (*matrix_)[i];
3335  }
3336 
3337  template<typename T>
3338  inline
3339  typename GrayscaleImage<T>::reference
3340  GrayscaleImage<T>::operator()(const typename GrayscaleImage<T>::size_type i,
3341  const typename GrayscaleImage<T>::size_type j)
3342  {
3343  return (*matrix_)[i][j];
3344  }
3345 
3346  template<typename T>
3347  inline
3348  typename GrayscaleImage<T>::const_reference
3349  GrayscaleImage<T>::operator()(const typename GrayscaleImage<T>::size_type i,
3350  const typename GrayscaleImage<T>::size_type j) const
3351  {
3352  return (*matrix_)[i][j];
3353  }
3354 
3355  template<typename T>
3356  inline
3357  typename GrayscaleImage<T>::reference
3358  GrayscaleImage<T>::operator()(const Point2d<typename GrayscaleImage<T>::size_type>& point2d)
3359  {
3360  return (*matrix_)(point2d);
3361  }
3362 
3363  template<typename T>
3364  inline
3365  typename GrayscaleImage<T>::const_reference
3366  GrayscaleImage<T>::operator()(const Point2d<typename GrayscaleImage<T>::size_type>& point2d) const
3367  {
3368  return (*matrix_)(point2d);
3369  }
3370 
3371 
3372  template<typename T>
3373  inline
3374  GrayscaleImage<T>
3376  const Range<int>& col_range)
3377  {
3378  assert((*this)[0] != 0);
3379  assert(row_range.is_valid());
3380  assert(row_range.start() < int(this->dim2()));
3381  assert(row_range.stop() < int(this->dim2()));
3382  assert(col_range.is_valid());
3383  assert(col_range.start() < int(this->dim1()));
3384  assert(col_range.stop() < int(this->dim1()));
3385  std::size_t rows = row_range.iterations();
3386  std::size_t cols = col_range.iterations();
3387  return GrayscaleImage<T>(rows+1,cols+1,matrix_->upper_left(row_range,col_range),
3388  matrix_->bottom_right(row_range,col_range));
3389  }
3390 
3391 
3392  template<typename T>
3393  inline
3394  std::string
3395  GrayscaleImage<T>::name() const {return "GrayscaleImage";}
3396 
3397  template<typename T>
3398  inline
3400  GrayscaleImage<T>::dim1() const {return matrix_->dim1();}
3401 
3402  template<typename T>
3403  inline
3405  GrayscaleImage<T>::height() const {return matrix_->dim1();}
3406 
3407  template<typename T>
3408  inline
3410  GrayscaleImage<T>::rows() const {return matrix_->dim1();}
3411 
3412  template<typename T>
3413  inline
3415  GrayscaleImage<T>::dim2() const {return matrix_->dim2();}
3416 
3417  template<typename T>
3418  inline
3420  GrayscaleImage<T>::width() const {return matrix_->dim2();}
3421 
3422  template<typename T>
3423  inline
3425  GrayscaleImage<T>::columns() const {return matrix_->dim2();}
3426 
3427  template<typename T>
3428  inline
3430  GrayscaleImage<T>::cols() const {return matrix_->dim2();}
3431 
3432  template<typename T>
3433  inline
3435  GrayscaleImage<T>::size() const {return matrix_->size();}
3436 
3437  template<typename T>
3438  inline
3441  {
3442  return typename GrayscaleImage<T>::size_type(-1)/sizeof(T);
3443  }
3444 
3445 
3446  template<typename T>
3447  inline
3448  bool GrayscaleImage<T>::empty()const {return matrix_->empty();}
3449 
3450  template<typename T>
3451  inline
3453  {
3454  matrix_->swap(*(M.matrix_));
3455  }
3456 
3457  template<typename T>
3458  inline
3460  {
3461  matrix_->operator+=(val);
3462  return *this;
3463  }
3464 
3465  template<typename T>
3466  inline
3468  {
3469  matrix_->operator-=(val);
3470  return *this;
3471 
3472  }
3473 
3474  template<typename T>
3475  inline
3477  {
3478  matrix_->operator*=(val);
3479  return *this;
3480  }
3481 
3482  template<typename T>
3483  inline
3485  {
3486  matrix_->operator/=(val);
3487  return *this;
3488  }
3489 
3490  template<typename T>
3491  inline
3493  {
3494  *matrix_ = matrix_->operator-();
3495  return *this;
3496  }
3497 
3498  template<typename T>
3499  inline
3501  {
3502  matrix_->operator+=(*(rhs.matrix_));
3503  return *this;
3504  }
3505 
3506  template<typename T>
3507  inline
3509  {
3510  matrix_->operator-=(*(rhs.matrix_));
3511  return *this;
3512  }
3513 
3514  template<typename T>
3515  inline
3517  {
3518  matrix_->operator*=(*(rhs.matrix_));
3519  return *this;
3520  }
3521 
3522  template<typename T>
3523  inline
3525  {
3526  matrix_->operator/=(*(rhs.matrix_));
3527  return *this;
3528  }
3529 
3530 
3531  template<typename T>
3532  inline
3534  {
3535  return matrix_->min();
3536  }
3537 
3538  template<typename T>
3539  inline
3541  {
3542  return matrix_->max();
3543  }
3544 
3545  template<typename T>
3546  inline
3548  {
3549  return matrix_->sum();
3550  }
3551 
3552  template<typename T>
3553  inline
3555  {
3556  matrix_->apply(fun);
3557  return *this;
3558  }
3559 
3560  template<typename T>
3561  inline
3563  {
3564  matrix_->apply(fun);
3565  return *this;
3566  }
3568  /* @{ */
3569  template<typename T>
3570  inline
3572  const GrayscaleImage<T>& M2)
3573  {
3574  assert(M1.dim1() == M2.dim1());
3575  assert(M1.dim2() == M2.dim2());
3576  GrayscaleImage<T> tmp(M1.dim1(),M1.dim2());
3577  std::transform(M1.begin(),M1.end(),M2.begin(),tmp.begin(),std::plus<T>());
3578  return tmp;
3579  }
3580 
3581  template<typename T>
3582  inline
3584  const T& val)
3585  {
3586  GrayscaleImage<T> tmp = M1;
3587  tmp += val;
3588  return tmp;
3589  }
3590 
3591  template<typename T>
3592  inline
3594  const GrayscaleImage<T>& M1)
3595  {
3596  return M1 + val;
3597  }
3598 
3599 
3600 template<typename T>
3601 inline
3603  const GrayscaleImage<T>& M2)
3604 {
3605  assert(M1.dim1() == M2.dim1());
3606  assert(M1.dim2() == M2.dim2());
3607  GrayscaleImage<T> tmp(M1.dim1(),M1.dim2());
3608  std::transform(M1.begin(),M1.end(),M2.begin(),tmp.begin(),std::minus<T>());
3609  return tmp;
3610 }
3611 
3612 template<typename T>
3613 inline
3615  const T& val)
3616 {
3617  GrayscaleImage<T> tmp = M1;
3618  tmp -= val;
3619  return tmp;
3620 }
3621 
3622 template<typename T>
3623 inline
3625  const GrayscaleImage<T>& M1)
3626 {
3627  return M1 - val;
3628 }
3629 
3630 template<typename T>
3631 inline
3633  const GrayscaleImage<T>& M2)
3634 {
3635  assert(M1.dim1() == M2.dim1());
3636  assert(M1.dim2() == M2.dim2());
3637  GrayscaleImage<T> tmp(M1.dim1(),M1.dim2());
3638  std::transform(M1.begin(),M1.end(),M2.begin(),tmp.begin(),std::multiplies<T>());
3639  return tmp;
3640 }
3641 
3642 template<typename T>
3643 inline
3645  const T& val)
3646 {
3647  GrayscaleImage<T> tmp = M1;
3648  tmp *= val;
3649  return tmp;
3650 }
3651 
3652 template<typename T>
3653 inline
3655  const GrayscaleImage<T>& M1)
3656 {
3657  return M1 * val;
3658 }
3659 
3660 template<typename T>
3661 inline
3663  const GrayscaleImage<T>& M2)
3664 {
3665  assert(M1.dim1() == M2.dim1());
3666  assert(M1.dim2() == M2.dim2());
3667  GrayscaleImage<T> tmp(M1.dim1(),M1.dim2());
3668  std::transform(M1.begin(),M1.end(),M2.begin(),tmp.begin(),std::divides<T>());
3669  return tmp;
3670 }
3671 
3672 template<typename T>
3673 inline
3675  const T& val)
3676 {
3677  GrayscaleImage<T> tmp = M1;
3678  tmp /= val;
3679  return tmp;
3680 }
3681 
3682 
3683 /* @} */
3684 
3685 
3691 template<typename T>
3692 inline
3693 T& min(const GrayscaleImage<T>& M1)
3694 {
3695  return M1.min();
3696 }
3702 template<typename T>
3703 inline
3704 T& max(const GrayscaleImage<T>& M1)
3705 {
3706  return M1.max();
3707 }
3708 
3710  /* @{ */
3711 template<typename T>
3712 inline
3714  const GrayscaleImage<T>& y)
3715 {
3716  return ( x.size() == y.size()
3717  && std::equal(x.begin(),x.end(),y.begin()));
3718 }
3719 
3720 template<typename T>
3721 inline
3723  const GrayscaleImage<T>& y)
3724 {
3725  return !(x == y);
3726 }
3727 /* @} */
3728 
3730  /* @{ */
3731 template<typename T>
3732 inline
3733 bool operator<(const GrayscaleImage<T>& x,
3734  const GrayscaleImage<T>& y)
3735 {
3736  return std::lexicographical_compare(x.begin(), x.end(),
3737  y.begin(), y.end());
3738 }
3739 
3740 //MoreThanComparable
3741 template<typename T>
3742 inline
3744  const GrayscaleImage<T>& y)
3745 {
3746  return (y < x);
3747 }
3748 
3749 //LessThanEqualComparable
3750 template<typename T>
3751 inline
3752 bool operator<=(const GrayscaleImage<T>& x,
3753  const GrayscaleImage<T>& y)
3754 {
3755  return !(y < x);
3756 }
3757 
3758 //MoreThanEqualComparable
3759 template<typename T>
3760 inline
3762  const GrayscaleImage<T>& y)
3763 {
3764  return !(x < y);
3765 }
3766 /* @} */
3767 
3768 }//slip::
3769 
3770 #endif //SLIP_GRAYSCALEIMAGE_HPP
GrayscaleImage< T > & apply(T(*fun)(T))
Applys the one-parameter C-function fun to each element of the GrayscaleImage.
slip::stride_iterator< const_pointer > const_row_range_iterator
void fill(InputIterator first, InputIterator last)
Fills the container range [begin(),begin()+size()) with a copy of the range [first,last)
reverse_row_iterator row_rbegin(const size_type row)
Returns a read/write reverse iterator that points to the last element of the row row in the Grayscale...
bool operator!=(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1448
std::size_t iterations() const
Rerturns the number of iterations of the range.
Definition: Range.hpp:305
size_type cols() const
Returns the number of columns (second dimension size) in the GrayscaleImage.
self & operator/=(const T &val)
bool empty() const
Returns true if the GrayscaleImage is empty. (Thus size() == 0)
iterator2d upper_left()
Returns a read/write iterator2d that points to the first element of the Matrix. It points to the uppe...
Definition: Matrix.hpp:3135
reference operator()(const size_type i, const size_type j)
Subscript access to the data contained in the GrayscaleImage.
col_iterator col_begin(const size_type col)
Returns a read/write iterator that points to the first element of the column column in the GrayscaleI...
size_type height() const
Returns the height (first dimension size) in the GrayscaleImage.
GrayscaleImage & operator=(const self &rhs)
Assign a GrayscaleImage.
const GrayscaleImage< T > const_self
reverse_iterator rbegin()
Returns a read/write reverse iterator that points to the last element in the GrayscaleImage. Iteration is done in reverse element order.
size_type dim2() const
Returns the number of columns (second dimension size) in the GrayscaleImage.
GrayscaleImage(const size_type height, const size_type width, InputIterator first, InputIterator last)
Contructs a GrayscaleImage from a range.
This is some iterator to iterate a 2d container into two Range defined by the indices and strides of ...
Definition: Array2d.hpp:119
iterator2d bottom_right()
Returns a read/write iterator2d that points to the past the end element of the Matrix. It points to past the end element of the bottom right element of the Matrix.
Definition: Matrix.hpp:3151
const_pointer const_row_iterator
T & min(const GrayscaleImage< T > &M1)
Returns the min element of a GrayscaleImage.
std::reverse_iterator< iterator > reverse_iterator
friend class boost::serialization::access
iterator begin()
Returns a read/write iterator that points to the first element in the GrayscaleImage. Iteration is done in ordinary element order.
Color< T > operator+(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:602
iterator begin()
Returns a read/write iterator that points to the first element in the Matrix. Iteration is done in or...
Definition: Matrix.hpp:2789
Provides a class to manipulate iterator2d within a slip::Box2d. It is used to iterate throw 2d contai...
void write_ascii(const std::string &file_path_name) const
Write the GrayscaleImage to an ASCII file.
slip::Matrix< T >::iterator2d_range iterator2d_range
T sum() const
Returns the sum of the elements of the GrayscaleImage.
std::reverse_iterator< const_iterator2d > const_reverse_iterator2d
~GrayscaleImage()
Destructor of the GrayscaleImage.
This is a grayscaleimage class. This is a two-dimensional dynamic and generic container. This container statisfies the BidirectionnalContainer concepts of the STL. It is also an 2d extension of the RandomAccessContainer concept. That is to say the bracket element access is replaced by the double bracket element access. Data are stored using a Matrix class. It extends the interface of Matrix adding image read/write operations. These operations are done using the ImageMagick library.
const value_type & const_reference
iterator end()
Returns a read/write iterator that points one past the last element in the GrayscaleImage. Iteration is done in ordinary element order.
slip::GrayscaleImage< short > GrayscaleImage_s
short alias
std::string name() const
Returns the name of the class.
size_type rows() const
Returns the number of rows (first dimension size) in the GrayscaleImage.
std::reverse_iterator< row_range_iterator > reverse_row_range_iterator
slip::stride_iterator< const_col_iterator > const_col_range_iterator
size_type columns() const
Returns the number of columns (second dimension size) in the GrayscaleImage.
size_type width() const
Returns the number of columns (second dimension size) in the GrayscaleImage.
slip::stride_iterator< col_iterator > col_range_iterator
slip::GrayscaleImage< long > GrayscaleImage_l
long alias
bool operator>(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1469
void resize(const size_type height, const size_type width, const T &val=T())
Resizes a GrayscaleImage.
const_pointer const_iterator
This is a point2d class, a specialized version of Point<CoordType,DIM> with DIM = 2...
Definition: Array2d.hpp:132
This is a Range class.
slip::Matrix< T >::const_iterator2d_range const_iterator2d_range
reverse_iterator rend()
Returns a read/write reverse iterator that points to one before the first element in the GrayscaleIma...
const_iterator2d const_default_iterator
slip::Matrix< T >::iterator2d iterator2d
static const std::size_t DIM
std::reverse_iterator< col_range_iterator > reverse_col_range_iterator
self & operator-=(const T &val)
This is some iterator to iterate a 2d container into a Box area defined by the indices of the 2d cont...
Definition: Array2d.hpp:122
row_iterator row_end(const size_type row)
Returns a read/write iterator that points one past the end element of the row row in the GrayscaleIma...
slip::GrayscaleImage< unsigned long > GrayscaleImage_ul
unsigned long alias
T & min() const
Returns the min element of the GrayscaleImage according to the operator <.
slip::GrayscaleImage< unsigned short > GrayscaleImage_us
unsigned long alias
std::reverse_iterator< const_row_range_iterator > const_reverse_row_range_iterator
slip::stride_iterator< pointer > col_iterator
slip::stride_iterator< pointer > row_range_iterator
iterator2d bottom_right()
Returns a read/write iterator2d that points to the past the end element of the GrayscaleImage. It points to past the end element of the bottom right element of the GrayscaleImage.
std::reverse_iterator< iterator > reverse_row_iterator
const value_type * const_pointer
void copy(_II first, _II last, _OI output_first)
Copy algorithm optimized for slip iterators.
Definition: copy_ext.hpp:177
bool is_valid() const
Returns true if the range is valid :
Definition: Range.hpp:322
SubType start() const
Accessor of the start subscript of the Range.
Definition: Range.hpp:284
std::reverse_iterator< const_iterator2d_range > const_reverse_iterator2d_range
slip::Matrix< T >::const_iterator2d const_iterator2d
size_type max_size() const
Returns the maximal size (number of elements) in the GrayscaleImage.
reverse_iterator2d rbottom_right()
Returns a read/write reverse iterator2d. It points to past the upper left element of the GrayscaleIma...
void read_ascii(const std::string &file_path_name)
Read the GrayscaleImage from an ASCII file.
size_type size() const
Returns the number of elements in the GrayscaleImage.
slip::GrayscaleImage< int > GrayscaleImage_i
int alias
This is some iterator to iterate a 2d container into a slip::Box2d area defined by the indices of the...
Definition: Array2d.hpp:116
GrayscaleImage()
Constructs a GrayscaleImage.
Provides some input/ouput algorithms.
self & operator*=(const T &val)
Numerical matrix class. This container statisfies the BidirectionnalContainer concepts of the STL...
reverse_col_iterator col_rbegin(const size_type col)
Returns a read/write reverse iterator that points to the last element of the column column in the Gra...
slip::GrayscaleImage< char > GrayscaleImage_c
char alias
reverse_iterator2d rupper_left()
Returns a read/write reverse iterator2d. It points to the bottom right element of the Matrix...
Definition: Matrix.hpp:3289
std::ostream & operator<<(std::ostream &out, const Array< T > &a)
Definition: Array.hpp:1282
void fill(const T *value)
Fills the container range [begin(),begin()+size()) with a copy of the value array.
void fill(const T &value)
Fills the container range [begin(),begin()+size()) with copies of value.
void swap(self &M)
Swaps data with another GrayscaleImage.
std::reverse_iterator< col_iterator > reverse_col_iterator
This is some iterator to iterate a 2d container into two Range defined by the indices and strides of ...
Definition: Array2d.hpp:125
self & operator+=(const T &val)
Add val to each element of the GrayscaleImage.
std::reverse_iterator< iterator2d > reverse_iterator2d
slip::GrayscaleImage< unsigned int > GrayscaleImage_ui
unsigned int alias
iterator end()
Returns a read/write iterator that points one past the last element in the Matrix. Iteration is done in ordinary element order.
Definition: Matrix.hpp:2796
slip::stride_iterator< const_pointer > const_col_iterator
Provides a class to manipulate Numerical Matrix.
Provides some algorithms to apply C like functions to ranges.
std::reverse_iterator< const_iterator > const_reverse_iterator
iterator2d upper_left()
Returns a read/write iterator2d that points to the first element of the GrayscaleImage. It points to the upper left element of the GrayscaleImage.
slip::GrayscaleImage< unsigned char > GrayscaleImage_uc
unsigned char alias
Provides a class to iterate a 1d range according to a step.
row_iterator row_begin(const size_type row)
Returns a read/write iterator that points to the first element of the row row in the GrayscaleImage...
reverse_row_iterator row_rend(const size_type row)
Returns a read/write reverse iterator that points one past the first element of the row row in the Gr...
bool operator==(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1439
slip::GrayscaleImage< double > GrayscaleImage_d
double alias
reverse_iterator2d rbottom_right()
Returns a read/write reverse iterator2d. It points to past the upper left element of the Matrix...
Definition: Matrix.hpp:3272
slip::GrayscaleImage< float > GrayscaleImage_f
float alias
col_iterator col_end(const size_type col)
Returns a read/write iterator that points one past the end element of the column column in the Graysc...
Color< T > operator*(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:658
Provides a class to manipulate iterator2d within a slip::Range. It is used to iterate throw 2d contai...
reverse_iterator2d rupper_left()
Returns a read/write reverse iterator2d. It points to the bottom right element of the GrayscaleImage...
std::reverse_iterator< const_iterator > const_reverse_row_iterator
pointer operator[](const size_type i)
Subscript access to the row datas contained in the GrayscaleImage.
reverse_col_iterator col_rend(const size_type col)
Returns a read/write reverse iterator that points one past the first element of the column column in ...
T & max(const GrayscaleImage< T > &M1)
Returns the max element of a GrayscaleImage.
SubType stop() const
Accessor of the stop subscript of the Range.
Definition: Range.hpp:291
Color< T > operator/(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:686
T & max() const
Returns the max element of the GrayscaleImage according to the operator <.
std::reverse_iterator< const_col_iterator > const_reverse_col_iterator
bool operator>=(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1485
Color< T > operator-(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:630
std::reverse_iterator< iterator2d_range > reverse_iterator2d_range
size_type dim1() const
Returns the number of rows (first dimension size) in the GrayscaleImage.
std::reverse_iterator< const_col_range_iterator > const_reverse_col_range_iterator