| 742 | } |
| 743 | |
| 744 | Image FlipImg(const Image& img) // in: flip image horizontally (mirror image) |
| 745 | { |
| 746 | Image workimg(img.isContinuous()? img: img.clone()); // need continuous image |
| 747 | const int width = workimg.cols; |
| 748 | const int height = workimg.rows; |
| 749 | Image outimg(height, width); |
| 750 | for (int iy = 0; iy < height; iy++) |
| 751 | { |
| 752 | int width1 = iy * width; |
| 753 | int ix1 = width; |
| 754 | for (int ix = 0; ix < width; ix++) |
| 755 | outimg.data[ix + width1] = workimg.data[--ix1 + width1]; |
| 756 | } |
| 757 | return outimg; |
| 758 | } |
| 759 | |
| 760 | void FlipImgInPlace(Image& img) // io: flip image horizontally (mirror image) |
| 761 | { |