本文实现将一幅图像旋转180度,不调用opencv库函数。
c++实现代码:
int myRotate180(IplImage* src, IplImage* dst)
{
int w_src = src ->widthStep;
int h_src = src ->height;
byte* gray_src = (byte*)src->imageData;
int w_dst = dst ->widthStep;
int h_dst = dst ->height;
byte* gray_dst = (byte*)dst->imageData;
for (int i = 0; i < h_dst; i++)
{
for (int j = 0; j < w_dst; j++)
{
gray_dst[i * w_dst + j] = gray_src[(h_src - i) * w_src + w_src - j];
}
}
return 0;
}