- This program demonstrates the use of the photometric stereo technique
- for the inspection of the flooring panels.
- Input are 4 images taken from flooring panels
- with light coming from different orientations.
- Initialization
dev_close_window ()
dev_update_off ()
dev_open_window (0, 0, 640, 512, ‘black’, WindowHandle)
set_display_font (WindowHandle, 14, ‘mono’, ‘true’, ‘false’)
Message := ‘Inspect the label of flooring panels’
Message[1] := ‘using photometric stereo. In this case four’
Message[2] := ‘different light orientations were used.’
disp_message (WindowHandle, Message, ‘window’, 12, 12, ‘black’, ‘true’)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop ()
for Index := 1 to 2 by 1
*- Show input images with different illumination
read_image (Images, ‘photometric_stereo/flooring_’ + Index + ‘_0’ + [1:4])
for I := 1 to 4 by 1
Message := ‘Acquire image ’ + I + ’ of 4’
select_obj (Images, ObjectSelected, I)
dev_display (ObjectSelected)
disp_message (WindowHandle, Message, ‘window’, 12, 12, ‘black’, ‘true’)
wait_seconds (0.5)
endfor - Apply photometric stereo to determine the albedo
- and the surface gradient.
Slants := [39.4,40.5,39.5,38.4]
Tilts := [-6.0,83.7,172.9,-98.2]
ResultType := [‘gradient’,‘albedo’]
photometric_stereo (Images, HeightField, Gradient, Albedo, Slants, Tilts, ResultType, ‘poisson’, [], []) - Display the albedo image
dev_display (Albedo)
disp_message (WindowHandle, ‘Albedo image’, ‘window’, 12, 12, ‘black’, ‘true’)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop () - Calculate the gaussian curvature of the surface
- using the gradient field as input for the operator
- derivate_vector_field.
- Defects are usually easy to detect in the curvature image.
derivate_vector_field (Gradient, MeanCurvature, 1.0, ‘mean_curvature’) - Detect defects
- Segment the tablet areas in the curvature image
threshold (MeanCurvature, Region, 0.02, 1000)
connection (Region, Defects)
area_center (Defects, Area, Row, Column)
gen_circle (Circle, Row, Column, sqrt(Area) + 10) - Display the defects in curvature image
dev_set_draw (‘margin’)
dev_set_color (‘red’)
dev_set_line_width (2)
dev_display (MeanCurvature)
dev_display (Circle)
Message := ‘The defects can easily be detected’
Message[1] := ‘in the surface curvature image’
disp_message (WindowHandle, Message, ‘window’, 12, 12, ‘black’, ‘true’)
stop () - Display the defects in the albedo image
dev_set_draw (‘margin’)
dev_set_color (‘red’)
dev_display (Albedo)
dev_display (Circle)
disp_message (WindowHandle, ‘Defects in albedo image’, ‘window’, 12, 12, ‘black’, ‘true’)
if (Index < 2)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop ()
endif
endfor
- Show input images with different illumination
haclcon_钢坯表面检测
最新推荐文章于 2024-05-27 10:23:29 发布