27 #ifndef MLN_IO_PLOT_SAVE_HH
28 # define MLN_IO_PLOT_SAVE_HH
36 # include <mln/core/image/image1d.hh>
37 # include <mln/util/array.hh>
38 # include <mln/histo/array.hh>
58 void save(
const image1d<I>& ima,
const std::string&
filename);
70 void save(
const util::array<T>& arr,
const std::string&
filename,
75 void save(
const histo::array<T>& arr,
const std::string&
filename);
77 # ifndef MLN_INCLUDE_ONLY
84 void save(
const image1d<T>& ima,
const std::string&
filename)
86 mln_trace(
"mln::io::plot::save");
88 std::ofstream file_out(filename.c_str());
89 unsigned end = ima.bbox().pmax().ind();
90 for (
unsigned i = ima.bbox().pmin().ind(); i <= end; ++i)
91 file_out << i <<
" " << ima.at_(i) << std::endl;
97 void save(
const util::array<T>& arr,
const std::string& filename,
100 mln_trace(
"mln::io::plot::save");
102 std::ofstream file_out(filename.c_str());
103 for (
unsigned i = 0; i < arr.nelements(); ++i)
104 file_out << start_value + i <<
" " << arr[i] << std::endl;
108 template <
typename T>
110 void save(
const histo::array<T>& arr,
const std::string& filename)
112 mln_trace(
"mln::io::plot::save");
114 std::ofstream file_out(filename.c_str());
115 for (
unsigned i = 0; i < arr.nvalues(); ++i)
116 file_out << i <<
" " << arr[i] << std::endl;
121 # endif // ! MLN_INCLUDE_ONLY
130 #endif // ! MLN_IO_PLOT_SAVE_HH