halcon 光度立体法
用分区光源在四个角度拍照四张图片进行组合,做字符识别
第一个角度的图片

第二个角度的图片

第三个角度的图片

第四个角度的图片

组合后图片

预处理后效果

代码
* Image Acquisition 01: Code generated by Image Acquisition 01
ImageFiles := []
ImageFiles[0] := 'C:/Users/ASUS/Desktop/光度立体法测试图像 - 副本/1.bmp'
ImageFiles[1] := 'C:/Users/ASUS/Desktop/光度立体法测试图像 - 副本/2.bmp'
ImageFiles[2] := 'C:/Users/ASUS/Desktop/光度立体法测试图像 - 副本/3.bmp'
ImageFiles[3] := 'C:/Users/ASUS/Desktop/光度立体法测试图像 - 副本/4.bmp'
gen_empty_obj (EmptyObject)
for Index := 0 to |ImageFiles| - 1 by 1
read_image (Image, ImageFiles[Index])
* Image Acquisition 01: Do something
rgb1_to_gray (Image, GrayImage)
concat_obj (EmptyObject, GrayImage, EmptyObject)
endfor
stop ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
for I := 1 to 4 by 1
Message := ' 组合图片 ' + I + ' of 4'
select_obj (EmptyObject, ObjectSelected, I)
dev_display (ObjectSelected)
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
wait_seconds (0.5)
stop ()
endfor
*
* Apply photometric stereo to determine the albedo and compute the mean
* curvature of the surface
Tilts := [6.1,95.0,-176.1,-86.8]
Slants := [75,75,75,75]
ResultType := ['gradient','albedo']
photometric_stereo (EmptyObject, HeightField, Gradient, Albedo, Slants, Tilts, ResultType, 'poisson', [], [])
*
* Display the albedo image
dev_display (Albedo)
disp_message (WindowHandle, 'The albedo image still has some artefacts', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*
* Calculate the mean curvature of the surface
* using the gradient field as input for the operator
* derivate_vector_field.
derivate_vector_field (Gradient, MeanCurvature, 1, 'mean_curvature')
*
* It is easy to segment the dots in the curvature image
dev_display (MeanCurvature)
disp_message (WindowHandle, '光度立体法组合图片', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
* stop ()
mean_image (MeanCurvature, ImageMean, 30, 30)
*将图片转到0-255
min_max_gray (ImageMean, ImageMean, 5, Min, Max, Range)
scale_image (ImageMean, ImageScaled, 255 / Range, -Min * 255 / Range)
convert_image_type (ImageScaled, ImageConverted, 'byte')
stop ()
1736

被折叠的 条评论
为什么被折叠?



