Halcon深度图转换(real、uint2、byte)

* real图
read_image (ImageReal, 'Real.tif')Min:=0
Max:=20
IsFixed:='false'* 输入real类型图像,输出三通道图像(real图像/uint2图像/byte图像)
DepthImageConvert (ImageReal, MultiChannelImage, Min, Max, IsFixed)
* real图无效点赋值
threshold (ImageReal, Region, 0, 9999)
difference (ImageReal, Region, RegionDifference)
get_region_points (RegionDifference, Rows, Columns)
tuple_gen_const (|Rows|, 0, Newtuple)
set_grayval (ImageReal, Rows, Columns, Newtuple)* real图转uint2图
min_max_gray (ImageReal, ImageReal, 0, Min, Max, Range)if (IsFixed=='true')Min:=MinValueMax:=MaxValueRange:=MaxValue-MinValue
endifget_region_points (ImageReal, Rows1, Columns1)
get_grayval (ImageReal, Rows1, Columns1, Grayval)
GrayvalUint2 := Min + Grayval*(65535 / Range)
get_image_size (ImageReal, Width, Height)
gen_image_const (ImageUin2, 'uint2', Width, Height)
set_grayval (ImageUin2, Rows1, Columns1, GrayvalUint2)* real图转灰度图
* min_max_gray (ImageReal, ImageReal, 0, MinValue, MaxValue, Range)
* get_region_points (ImageReal, Rows1, Columns1)
* get_grayval (ImageReal, Rows1, Columns1, Grayval)
Grayvalint1 := Min + Grayval*(255 / Range)
*get_image_size (ImageReal, Width, Height)
gen_image_const (ImageGray, 'byte', Width, Height)
set_grayval (ImageGray, Rows1, Columns1, Grayvalint1)compose3 (ImageReal, ImageUin2, ImageGray, MultiChannelImage)
return ()