C语言数字图像处理(三):仿射变换

0. 完整仓库 & 教程:

这一章节的完整代码在:Chapter 3. Affine Transformation and Smoothing

如果你喜欢这个系列的文章或者感觉对你有帮助,请给我的仓库一个⭐️

1. 恒等变换

算法:

后续代码将以固定距离平移图像。

图像和结果对比(lena, circles):

结果分析:

通过在水平和竖直方向上移动图像中所有像素,从而达到平移的效果。移动后的黑色背景中不包含任何信息。这种方法速度快,不会导致任何像素值的改变。

代码实现(完整代码见顶部GitHub):
// set the background of the whole image to black(0):
for(int i = 0; i < outimage->Height; i++) {
    for(int j = 0; j < outimage->Width; j++){
        tempout[(outimage->Width)*i + j] = 0;
    }
}

for(int i = 0; i < image->Height; i++) {
    for(int j = 0; j < image->Width; j++){
        // in case the coordinates + offsets beyond the boundary:
        if((j+72) >= outimage->Width || (i+72) >= outimage->Height) continue;
        else tempout[(outimage->Width)*(i+72) &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值