Skip to content

Instantly share code, notes, and snippets.

@SubhiH
Last active July 13, 2023 05:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SubhiH/b519c222ee040f4bd5f1ce5ddaeee8c5 to your computer and use it in GitHub Desktop.
Save SubhiH/b519c222ee040f4bd5f1ce5ddaeee8c5 to your computer and use it in GitHub Desktop.
Flip image horizontally and vertically
void ImageOperator::flip_h(const unsigned char* input,
const int width,
const int height,
const int channel,
unsigned char*& output){
for (int row = 0; row < height; ++row) {
for (int col = 0; col < width * channel; col += 1) {
output[row*width+col]=input[(height-row)*width+col];
}
}
}
void ImageOperator::flip_v(const unsigned char* input,
const int width,
const int height,
const int channel,
unsigned char*& output){
for (int row = 0; row < height; ++row) {
for (int col = 0; col < width * channel; col += 1) {
output[row*width+col]=input[row*width+(width-col)];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment