C语言数字图像处理,如何将两张图片合在一块。(本人刚学,不太懂,程序如何设计)

C语言数字图像处理,如何将两张图片合在一块。(本人刚学,不太懂,程序如何设计),第1张

1. C++没有提供删除std::(w)string的前后空格的函数,比如TrimSpace.

2. 很多库都提供, 但是为了移植代码链培方便,最好还是能用标准库解决斗陆就棚销唯用标准库.

算法描述

procedure ImageMatching

{

输入FirstImage

输入SecondImage

//获得两幅图象的大小

Height1=GetImageHeight(FirstImage)

Height2=GetImageHeight(SecondImage)

Width1=GetImageWidth(FirstImage)

Width2=GetImageWidth(SecondImage)

// 从第二幅图象取网格匹配模板

SecondImageGrid = GetSecondImageGrid(SecondImage)

// 粗略匹配,网格在第一幅图象中先从左向右移动,再从下到上移动,每次移动一个宽空网格间距,Step_Width 或Step_Height,当网格移出重叠区域后结束

y=Heitht1-GridHeight

MinValue = MaxInteger

While ( y<Height1-OverlapNumber)//当网格移出重叠部分后结束州巧渗

{

x=Grid_Width/2//当网格位于第一幅图象的最左边册脊时,A点的横坐标。

While ( x<(Width1-Grid_Width/2) )

{

FirstImageGrid=GetImgaeGrid(FirstImgaeGrid, x, y)

differ=CaculateDiff(FirstImgaeGrid, SecondImageGrid)//计算象素值差的平

//方和

if (differ<MinValue)

{

BestMatch_x=x

BestMatch_y=y

MinValue = differ

}

x= x+Step_width

}

y=y-Step_Height

}

//精确匹配

Step_Width= Step_Width/2

Step_Height= Step_Height/2

While ( Step_Height>0 &Step_Width>0)//当水平步长和垂直步长均减为零时结束

{

if(Step_Height==0)//当仅有垂直步长减为零时,将其置为1

Step_Height=1

If(Step_Width==0) //当仅有水平步长减为零时,将其置为1

Step_Width=1

temp_x = BestMatch_x

temp_y = BestMatch_y

for ( i= -1i<1i++)

for( j= -1j<1j++)

{

if ((i=0&j!=0)|(i!=0&j=0))

{

FirstImageGrid=GetImgaeGrid(FirstImgaeGrid,

temp_x+i*Step_Width, temp_y +j*Step_Height)

differ=CaculateDiff(FirstImgaeGrid, SecondImageGrid)

if (differ<MinValue)

{

BestMatch_x=x

BestMatch_y=y

MinValue = differ

}

}

}

Step_Height = Step_Height /2

Step_Width = Step_Width/2

}

}

不懂的可以问我,相互交流


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12320169.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存