};
int templt2[3][3] = {
{1,1,-1},
{1,-2,-1},
{1,1,-1}
};
int templt3[3][3] = {
{1,-1,-1},
{1,-2,-1},
{1,1,1}
};
int templt4[3][3] = {
{-1,-1,-1},
{1,-2,1},
{1,1,1}
};
int templt5[3][3] = {
{-1,-1,1},
{-1,-2,1},
{1,1,1}
};
int templt6[3][3] = {
{-1,1,1},
{-1,-2,1},
{-1,1,1}
};
int templt7[3][3] = {
{1,1,1},
{-1,-2,1},
{-1,-1,1}
};
int templtsize = 3;
int a =0;
for(int y = templtsize/2; y < image->height() - templtsize/2; y++)
{
for(int x = templtsize/2; x < image->width() - templtsize/2;x++)
{
int r =0;
int g = 0;
int b = 0;
for(int j = -templtsize/2; j <=templtsize/2;j++)
{
for(int i = -templtsize/2; i <= templtsize/2;i++)
{
color0 = QColor(image->pixel(x + i,y + j));
r += color0.red() * templt[i + templtsize/2][j + templtsize/2];
g += color0.green() * templt[i + templtsize/2][j + templtsize/2];
b += color0.blue() * templt[i + templtsize/2][j + templtsize/2];
}
}
r*= scale;
g*=scale;
b*=scale;
r = qBound(0,r,255);
g = qBound(0,g,255);
b = qBound(0,b,255);
newImage->setPixel(x,y,qRgb(r,g,b));
}
}
return newImage;
}
#### **3.下载路径**:
整个系列链接: [https://blog.csdn.net/m0\_59023219/category\_12425183.html](https://gitee.com/vip204888)
内容介绍:
[1]根据算法原理,编写纯c++源码,不调用外源库opencv 等;
[2]包括各种图像处理的基本算法,包含腐蚀膨胀,缩放,转置,镜像,平移,均衡变化,灰度拉升,灰度阈值,灰度非线性,转灰度,灰度线性,旋转,简单平滑,高斯平滑,轮廓跟踪,种子算法,hough直线检测,拉普拉斯,带方向边缘检测,常规边缘检测(梯度算子、Roberts算子和Sobel算子),中值滤波,反色操作等;
[3]程序中有完整的注释,便于大家很好理解代码。
代码下载路径:[基于QT的C++多种图像处理基本算法源码](https://gitee.com/vip204888)
**收集整理了一份《2024年最新物联网嵌入式全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升的朋友。**


**[如果你需要这些资料,可以戳这里获取](https://gitee.com/vip204888)**
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人**
**都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**