基于opencv的图像的无失真放大

来源:互联网 发布:php工作流引擎 编辑:程序博客网 时间:2024/05/22 15:51
//无失真放大
void DistortionFreeAmplification(const Mat& tmpGrayMat, Mat& dstMat, int times = 8)
{
dstMat = cv::Mat(tmpGrayMat.rows * times, tmpGrayMat.cols * times, tmpGrayMat.type());
for (int i=0; i<tmpGrayMat.rows; i++)
{
for (int j=0; j<tmpGrayMat.cols; j++)
{
const uchar * qtr = tmpGrayMat.ptr<uchar>(i, j);
for (int k=0; k<times; k++)
{
for (int l=0; l<times; l++)
{
uchar * ptr = dstMat.ptr<uchar>(times * i + l, times * j + k);
for (int m = 0; m < tmpGrayMat.channels(); m++)
{
ptr[m] = qtr[m];
}
}
}
}
}
}