Skip to content

Instantly share code, notes, and snippets.

@sgss
Last active December 12, 2015 02:58
Show Gist options
  • Save sgss/4702862 to your computer and use it in GitHub Desktop.
Save sgss/4702862 to your computer and use it in GitHub Desktop.
template <typename I, typename O, typename Iterator>
inline void transform_image(
const cv::Mat_<I>& input,
cv::Mat_<O> *output,
Iterator iterator) {
if (input.size != output->size) {
DR_LOGE("Dimensions of input and output images must be identical.");
DR_LOGD("Skipping the rest.");
return;
}
const int rows = input.rows;
const int cols = input.cols;
for (int y = 0; y < rows; ++y) {
const I *in_row = input[y];
O *out_row = (*output)[y];
for (int x = 0; x < cols; ++x) {
iterator(in_row[x], &out_row[x]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment