Add templates back. Remove --energy-recompute-all
This commit is contained in:
parent
55623c2ae9
commit
affb89c76e
@ -15,7 +15,6 @@
|
|||||||
// Global flags
|
// Global flags
|
||||||
bool silent = false;
|
bool silent = false;
|
||||||
bool test_energy = false;
|
bool test_energy = false;
|
||||||
bool energy_recompute_all = false;
|
|
||||||
int max_step = 1;
|
int max_step = 1;
|
||||||
|
|
||||||
// Get index for any table indexed by [width*(i : height) + (j : width)], but a
|
// Get index for any table indexed by [width*(i : height) + (j : width)], but a
|
||||||
@ -34,6 +33,10 @@ std::pair<int, float> operator+(std::pair<int, float>& p1, std::pair<int, float>
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator+=(std::pair<int, float>& p1, std::pair<int, float>& p2) {
|
||||||
|
p1 = p1+p2;
|
||||||
|
}
|
||||||
|
|
||||||
void export_image(const char *filename, const void *data, int width, int height,
|
void export_image(const char *filename, const void *data, int width, int height,
|
||||||
int nbChannels) {
|
int nbChannels) {
|
||||||
if (!silent)
|
if (!silent)
|
||||||
@ -117,7 +120,7 @@ template <typename T> std::vector<int> optimal_seam(std::vector<T> energy, int w
|
|||||||
dyn_energy[dim_large * i + j], dyn_energy[dim_large * (i - 1) + k]
|
dyn_energy[dim_large * i + j], dyn_energy[dim_large * (i - 1) + k]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
dyn_energy[dim_large * i + j] = dyn_energy[dim_large * i + j]+energy[im_index(i, j)];
|
dyn_energy[dim_large * i + j] += energy[im_index(i, j)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,11 +258,11 @@ void recompute_energy_along_seam(
|
|||||||
|
|
||||||
/** Carves an image and its energy by one seam, and recomputes the energy.
|
/** Carves an image and its energy by one seam, and recomputes the energy.
|
||||||
Returns the optimal seam used */
|
Returns the optimal seam used */
|
||||||
//template <typename T>
|
template <typename T>
|
||||||
std::vector<int> carving_step(const std::vector<unsigned char> source_img,
|
std::vector<int> carving_step(const std::vector<unsigned char> source_img,
|
||||||
std::vector<std::pair<int, float>> source_energy,
|
std::vector<T> source_energy,
|
||||||
std::vector<unsigned char> &output_img,
|
std::vector<unsigned char> &output_img,
|
||||||
std::vector<std::pair<int, float>> &output_energy, int width,
|
std::vector<T> &output_energy, int width,
|
||||||
int height, int nbChannels, int nbColorChannels,
|
int height, int nbChannels, int nbColorChannels,
|
||||||
bool vertical) {
|
bool vertical) {
|
||||||
|
|
||||||
@ -368,11 +371,11 @@ void seam_carving(unsigned char *source, int width, int height, int nbChannels,
|
|||||||
source_img, masked_energy, output_img, output_masked_energy,
|
source_img, masked_energy, output_img, output_masked_energy,
|
||||||
curWidth, curHeight, nbChannels, nbColorChannels, vertical
|
curWidth, curHeight, nbChannels, nbColorChannels, vertical
|
||||||
);
|
);
|
||||||
//} else {
|
} else {
|
||||||
// opt_seam = carving_step(
|
opt_seam = carving_step(
|
||||||
// source_img, source_energy, output_img, output_energy,
|
source_img, source_energy, output_img, output_energy,
|
||||||
// curWidth, curHeight, nbChannels, nbColorChannels, vertical
|
curWidth, curHeight, nbChannels, nbColorChannels, vertical
|
||||||
// );
|
);
|
||||||
}
|
}
|
||||||
std::copy(output_img.begin(), output_img.end(), source_img.begin());
|
std::copy(output_img.begin(), output_img.end(), source_img.begin());
|
||||||
std::copy(output_energy.begin(), output_energy.end(),
|
std::copy(output_energy.begin(), output_energy.end(),
|
||||||
@ -440,8 +443,6 @@ int main(int argc, char **argv) {
|
|||||||
app.add_flag("--silent", silent, "No verbose messages");
|
app.add_flag("--silent", silent, "No verbose messages");
|
||||||
app.add_flag("--test-energy", test_energy,
|
app.add_flag("--test-energy", test_energy,
|
||||||
"Don't resize image, just try the specified energy function");
|
"Don't resize image, just try the specified energy function");
|
||||||
app.add_flag("--energy-recompute-all", energy_recompute_all,
|
|
||||||
"recompute the whole energy at each step");
|
|
||||||
CLI11_PARSE(app, argc, argv);
|
CLI11_PARSE(app, argc, argv);
|
||||||
|
|
||||||
// Image loading
|
// Image loading
|
||||||
|
Loading…
x
Reference in New Issue
Block a user