测试 halcon measure_projection 算子

期望结果完全相同,但是下面的测试结果和halcon的差值如下:

[0.132838, 0.231991, 0.265157, 0.296903, 0.0998573, 0.165907, 0.230686, 0.130266, 0.0977104, 0.197109, 0.198173, 0.197086, 0.190943, 0.177665, 0.163521, 0.146541, 0.161362, 0.166666, 0.22818, 0.186114, 0.196333, 0.255945, 0.14496, 0.205199, 0.262202, 0.201859, 0.173616, 0.173016, 0.173485, 0.173227, 0.171494, 0.257541, 0.171186, 0.141769, 0.0852231, 0.257203, 0.198859, 0.170551, 0.25673, 0.171491, 0.170175, 0.169464, 0.198114, 0.169922, 0.169473, 0.1695, 0.168997, 0.139408, 0.195358, 0.193962, 0.221091, 0.19246, 0.246518, 0.138458, 0.194492, 0.193142, 0.217299, 0.188277, 0.16121, 0.106746, 0.106695, 0.104717, 0.154996, 0.17956, 0.199884, 0.174948, 0.174217, 0.125464, 0.234857, 0.197361, 0.239242, 0.217724, 0.220922, 0.160648, 0.19362, 0.1959, 0.196964, 0.197266, 0.229685, 0.193291, 0.191924, 0.191487, 0.288308, 0.191503, 0.223271, 0.285233, 0.0954785, 0.157538, 0.187701, 0.284095, 0.190475, 0.18948, 0.188329, 0.187838, 0.186164, 0.217482, 0.277055, 0.215032, 0.15109, 0.27215, 0.211512, 0.208731, 0.286509, 0.262083, 0.31329, 0.315317, 0.358043, 0.396789, 0.403176, 0.397609, 0.39305, 0.392336, 0.19589, 0.260681, 0.459158, 0.330526, 0.19935, 0.587357, 0.518498, 0.44198, 0.24967]

结果并不小,不知道问题出在哪里?

get_grayval_interpolated 和自己实现的双线性差值的结果是完全相同的

dev_close_window()

dev_open_window (0, 0, 512, 512, 'black', WindowHandle)

dev_set_window (WindowHandle)

read_image (Image, 'fabrik')

get_image_size (Image, Width, Height)

CenterRow:=Height/2-50

CenterCol:=Width/2

degPhi:=45

Phi:=rad(degPhi)

Length1:=60

Length1:=int(floor(Length1))

Length2:=1

gen_measure_rectangle2 (CenterRow, CenterCol, -Phi, Length1, Length2, Width, Height, 'bilinear', MeasureHandle)

measure_projection (Image, MeasureHandle, GrayValues)

disp_rectangle2(WindowHandle,CenterRow, CenterCol, -Phi, Length1, Length2)

RowAry:=[]

ColAry:=[]

RowAry[Length1]:=CenterRow

ColAry[Length1]:=CenterCol

RowOffsetAry[Length2]:=0

ColOffsetAry[Length2]:=0

clockWise:=true

if(clockWise)

Phi2:=rad(degPhi-90)

else

Phi2:=rad(degPhi+90)

endif

RowOffsetStep:=sin(Phi2)

ColOffsetStep:=cos(Phi2)

for Index := 1 to Length2 by 1

RowOffsetAry[Length2+Index]:=RowOffsetStep*Index

ColOffsetAry[Length2+Index]:=ColOffsetStep*Index

RowOffsetAry[Length2-Index]:=-RowOffsetAry[Length2+Index]

ColOffsetAry[Length2-Index]:=-ColOffsetAry[Length2+Index]

endfor

gen_image_const (Image1, 'real', Length1*2+1, Length2*2+1)

get_image_size (Image1, Width1, Height1)

RowOffsetStep:=sin(Phi)

ColOffsetStep:=cos(Phi)

for Index := 1 to Length1 by 1

RowAry[Length1+Index]:=CenterRow+Index*RowOffsetStep

ColAry[Length1+Index]:=CenterCol+Index*ColOffsetStep

RowAry[Length1-Index]:=CenterRow-Index*RowOffsetStep

ColAry[Length1-Index]:=CenterCol-Index*ColOffsetStep

endfor

GrayValues2:=[]

copy_image(Image, DupImage)

for Index := 0 to Width1-1 by 1

get_grayval_interpolated (Image, RowAry[Index], ColAry[Index], 'bilinear', Grayval)

left:= int(floor(ColAry[Index]))

right:=left+1

top:= int(floor(RowAry[Index]))

bottom:=top+1

a:=ColAry[Index]-left

b:=RowAry[Index]-top

get_grayval(Image,top,left,topLeftGrayVal)

get_grayval(Image,top,right,topRightGrayVal)

get_grayval(Image,bottom,left,bottomLeftGrayVal)

get_grayval(Image,bottom,right,bottomRightGrayVal)

Grayval:=(1 - a)*(1 - b)*topLeftGrayVal+ a*(1 - b)*topRightGrayVal +(1 - a)*b*bottomLeftGrayVal + a*b*bottomRightGrayVal

set_grayval (Image1, Length2, Index, Grayval)

set_grayval(DupImage,int(RowAry[Index]),int(ColAry[Index]),0)

AVGGrayVal:=Grayval

for Index2 := 1 to Length2 by 1

Row:=RowAry[Index]+RowOffsetAry[Length2+Index2]

Col:=ColAry[Index]+ColOffsetAry[Length2+Index2]

get_grayval_interpolated (Image, Row, Col, 'bilinear', Grayval)

left:= int(floor(Col))

right:=left+1

top:= int(floor(Row))

bottom:=top+1

a:=Col-left

b:=Row-top

get_grayval(Image,top,left,topLeftGrayVal)

get_grayval(Image,top,right,topRightGrayVal)

get_grayval(Image,bottom,left,bottomLeftGrayVal)

get_grayval(Image,bottom,right,bottomRightGrayVal)

Grayval:=(1 - a)*(1 - b)*topLeftGrayVal+ a*(1 - b)*topRightGrayVal +(1 - a)*b*bottomLeftGrayVal + a*b*bottomRightGrayVal

set_grayval (Image1, Length2+Index2, Index, Grayval)

set_grayval(DupImage,int(Row),int(Col),0)

AVGGrayVal:=AVGGrayVal+Grayval

Row:=RowAry[Index]+RowOffsetAry[Length2-Index2]

Col:=ColAry[Index]+ColOffsetAry[Length2-Index2]

get_grayval_interpolated (Image, Row, Col, 'bilinear', Grayval)

left:= int(floor(Col))

right:=left+1

top:= int(floor(Row))

bottom:=top+1

a:=Col-left

b:=Row-top

get_grayval(Image,top,left,topLeftGrayVal)

get_grayval(Image,top,right,topRightGrayVal)

get_grayval(Image,bottom,left,bottomLeftGrayVal)

get_grayval(Image,bottom,right,bottomRightGrayVal)

Grayval:=(1 - a)*(1 - b)*topLeftGrayVal+ a*(1 - b)*topRightGrayVal +(1 - a)*b*bottomLeftGrayVal + a*b*bottomRightGrayVal

set_grayval (Image1, Length2-Index2, Index, Grayval)

set_grayval(DupImage,int(Row),int(Col),0)

AVGGrayVal:=AVGGrayVal+Grayval

endfor

AVGGrayVal:=AVGGrayVal/Height1

GrayValues2[Index]:=AVGGrayVal

endfor

for Index := 0 to |GrayValues2|-1 by 1

GrayValuesDidff[Index]:=GrayValues2[Index]-GrayValues[Index]

endfor

相关推荐
VertexGeek8 分钟前
Rust学习(八):异常处理和宏编程:
学习·算法·rust
石小石Orz8 分钟前
Three.js + AI:AI 算法生成 3D 萤火虫飞舞效果~
javascript·人工智能·算法
jiao_mrswang1 小时前
leetcode-18-四数之和
算法·leetcode·职场和发展
qystca1 小时前
洛谷 B3637 最长上升子序列 C语言 记忆化搜索->‘正序‘dp
c语言·开发语言·算法
薯条不要番茄酱1 小时前
数据结构-8.Java. 七大排序算法(中篇)
java·开发语言·数据结构·后端·算法·排序算法·intellij-idea
今天吃饺子1 小时前
2024年SCI一区最新改进优化算法——四参数自适应生长优化器,MATLAB代码免费获取...
开发语言·算法·matlab
是阿建吖!1 小时前
【优选算法】二分查找
c++·算法
王燕龙(大卫)1 小时前
leetcode 数组中第k个最大元素
算法·leetcode
不去幼儿园2 小时前
【MARL】深入理解多智能体近端策略优化(MAPPO)算法与调参
人工智能·python·算法·机器学习·强化学习
Mr_Xuhhh2 小时前
重生之我在学环境变量
linux·运维·服务器·前端·chrome·算法