Skip to content

Instantly share code, notes, and snippets.

@reinaldorauch
Created December 6, 2017 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reinaldorauch/8bb0dfa27738f42a7d09e4818ed24839 to your computer and use it in GitHub Desktop.
Save reinaldorauch/8bb0dfa27738f42a7d09e4818ed24839 to your computer and use it in GitHub Desktop.
Mat invertImage(Mat image) {
Vec3b p;
for (int i = 0; i < image.rows; ++i)
{
for (int j = 0; j < image.cols; ++j)
{
p = image.at<Vec3b>(i, j);
image.at<Vec3b>(i, j)[0] = 255 - p[0];
image.at<Vec3b>(i, j)[1] = 255 - p[1];
image.at<Vec3b>(i, j)[2] = 255 - p[2];
}
}
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment