ivl 679
ivl/details/image/impl/image_impl.hpp
00001 /* This file is part of the ivl C++ library <http://image.ntua.gr/ivl>.
00002    A C++ template library extending syntax towards mathematical notation.
00003 
00004    Copyright (C) 2012 Yannis Avrithis <iavr@image.ntua.gr>
00005    Copyright (C) 2012 Kimon Kontosis <kimonas@image.ntua.gr>
00006 
00007    ivl is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU Lesser General Public License 
00009    version 3 as published by the Free Software Foundation.
00010 
00011    Alternatively, you can redistribute it and/or modify it under the terms 
00012    of the GNU General Public License version 2 as published by the Free 
00013    Software Foundation.
00014 
00015    ivl is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00018    See the GNU General Public License for more details.
00019 
00020    You should have received a copy of the GNU General Public License 
00021    and a copy of the GNU Lesser General Public License along 
00022    with ivl. If not, see <http://www.gnu.org/licenses/>. */
00023 
00024 #include "image.hpp"
00025 #include "../../exception.hpp"
00026 
00027 namespace ivl {
00028 namespace image_details {
00029 // ...
00030 } /* namespace iamge_details */
00031 
00032 // --------------------------------------------------------
00033 // Print functions
00034 /*
00035 template<class T, class D>
00036 std::ostream& print_array_nd (std::ostream& os, const array_nd<T,D>& a, bool float_point = false)
00037 {
00038         std::ios::fmtflags saveflags = os.flags(); // save formatting flags
00039 
00040         if(float_point)
00041                 os << std::fixed << std::setprecision(4);
00042 
00043         if (a.ndims() == 1) {
00044                 os << "[";
00045                 for (size_t j = 0; j < a.length(); ++j) {
00046                         print_nd_val(os, a[j]);
00047                 }
00048                 os << "]";
00049 
00050                 os.flags(saveflags) ; // restore formatting flags
00051                 return os;
00052         }
00053 
00054         size_array indices(a.ndims(), size_t(0));
00055         size_t i, offs;
00056         while (true) {
00057                 offs = 0;
00058                 if (a.ndims() > 2) {
00059                         // compute offset for block
00060                         for (size_t j = 2; j < a.ndims(); j++)
00061                                 offs += indices[j] * a.stride()[j];
00062                         // print coordinates
00063                         os << std::endl << "[";
00064                         for (size_t j = a.ndims() - 1; j > 1; j--)
00065                                 os << (j < a.ndims() - 1 ? ", " : "") << indices[j];
00066                         os << "]" << std::endl;
00067                 }
00068                 // print current 2-d block
00069                 for (size_t k = 0; k < a.size_nd()[0]; ++k) {
00070                         for (size_t j = 0; j < a.size_nd()[1]; ++j)
00071                                 print_nd_val(os, a[offs + j * a.stride()[1] + k]);
00072                         os << std::endl;
00073                 }
00074                 // increment indices
00075                 bool more = false;
00076                 i = 1;
00077                 while (++i < a.ndims()) // while (0 < i--)
00078                         if (++indices[i] < a.size_nd()[i]) {
00079                                 more = true;
00080                                 break;
00081                         } else
00082                                 indices[i] = 0; // carry to more-significant index
00083 
00084                 if (!more)
00085                         break; // No more elements.
00086         }
00087         if (a.ndims() == 1)
00088                 os << "]";
00089         os.flags(saveflags) ; // restore formatting flags
00090         return os;
00091 }
00092 */
00093 
00094 
00095 } /* namespace ivl */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations