Add a first version of iterative seam carving.
[seam-carving.git] / src / seam_main.cc
blob76de76a399ac44e6c6dcfcd49bb73666b77e36d9
1 #include <iostream>
2 #include <vector>
4 #include <boost/foreach.hpp>
6 #include <mln/io/ppm/save.hh>
7 #include <mln/literal/colors.hh>
9 #include "all.hh"
11 using namespace mln;
12 using namespace mln::value;
14 std::vector<unsigned>
15 carve_vertical_seam (const image2d<float> img);
17 int main (int argc, char** argv)
19 if (argc != 3)
21 std::cerr << "usage: " << *argv << " in.ppm out.ppm\n";
22 return 1;
25 image2d<rgb8> img = load (argv[1]);
26 image2d<float> nrg = get_nrg (img);
27 std::vector<unsigned> seam_path = carve_vertical_seam (nrg);
28 unsigned row = 0;
29 BOOST_FOREACH (unsigned col, seam_path)
31 img.at (row, col) = literal::red;
32 ++row;
34 io::ppm::save (img, argv[2]);