#include // Get index for any table indexed by [width*(i : height) + (j : width)], but a // : dim_long, b : dim_large #define im_index(a, b) (vertical ? (width * a + b) : (width * b + a)) bool does_seam_remove_mask(std::vector> energy, int width, int height, int nbChannels, std::vector opt_seam, bool vertical); std::vector> mask_energy(std::vector energy, int width, int height, unsigned char *mask); //* Operators overwrites std::pair operator+(std::pair &p1, std::pair &p2); void operator+=(std::pair &p1, std::pair &p2); bool operator==(std::pair &p1, std::pair &p2); // Unfortunately, std::cout << (std::pair<>) does not work and can't be // rewritten std::string str_of_e(std::pair energy); std::string str_of_e(float energy); namespace limits { struct max_energy { template operator T() { return std::numeric_limits::max(); } operator std::pair() { return {3, std::numeric_limits::max()}; } }; struct null_energy { template operator T() { return 0.; } operator std::pair() { return {0, limits::null_energy()}; } }; } // namespace limits template void compute_seam_tot(std::vector opt_seam, std::vector energy, int width, int height, bool vertical) { int dim_long = vertical ? height : width; T sum = limits::null_energy(); for (int i = 0; i < dim_long; i++) { sum += energy[im_index(i, opt_seam[i])]; // std::cout << str_of_e(sum); } std::cout << "Computed sum: " << str_of_e(sum) << std::endl; }