1
© 2003-2009 MVTec Software GmbH
Depth from Focus
Depth From Focus: Idea
n Within a scene object points have different distances to the camera
n The camera has a limited depth of field
n Depending on the distance and the focus different object points are
displayed sharply in the image
n Taking images with various object distances each object point can be
displayed sharply in at least one image
n By determining in which image an
object point is projected sharply the
distance can be determined
Concept: Basic Process Steps
Depth from
focus
Focus
Series
Depth
image
Sharp
Image
Operator: depth_from_focus
Apply the depth from focus method
Determine
n Depth map, i.e., the distance for each pixel
n Confidence of the distance value
Usage
n Use the focus series as input
n Select the appropriate filter method
n Get the depth information as an index for each pixel
Parameters
n MultiFocusImage: Focus series as multi channel image
n Depth: Index image where the value for each pixel corresponds to the
index of the image with the maximum sharpness
n Confidence: Reliability of the depth measurement
n Filter: Filter type to determine the sharpness
n Selection: Handling of points with low confidence
select_grayvalues_from_channels
Reconstruction of a sharp image
Determine
n Select the sharpest gray value for each coordinate
n Use the depth image as index table
Usage
n Use the focus series and the depth image as input
n Reconstruct the focused image
Parameters
n MultiChannelImage: Focus series as multi channel image
n IndexImage: Depth image used as index table
n Selected: Reconstructed sharp image
Rules to Take Images
n Avoid overexposure
n Use camera with a wide dynamic range
n Use a camera with low noise
n Use diffusive illumination
n Avoid reflections
n Cover the whole distance range
n Use at least 10 images
n The maximum number of images is limited by the camera noise
n Do not move the camera or the object
n The distance between the light source and the object should remain
constant
2
Handling of Image Sequences
Read a multichannel image in one step
Names := []
for i := 1 to 10 by 1
Names := [Names,'dff/focus_'+(i$'.2')]
endfor
read_image (Image, Names)
Handling of Image Sequences
Combine all images grabbed to a multi channel image
Handle the data as a sequence of images in an image tuple
grab_image(MultiChannelImage , FGHandle)
for i := 1 to 10 by 1
grab_image(Image, FGHandle)
append_channel(MultiChannelImage, Image, TmpImage)
copy_obj(TmpImage, MultiChannelImage, 1, 1)
endfor
grab_image(ImageTuple , FGHandle)
for i := 1 to 10 by 1
grab_image(Image, FGHandle)
concat_obj(ImageTuple, Image, TmpImage)
copy_obj(TmpImage, ImageTuple, 1, -1)
endfor
channels_to_image(ImageTuple, MultiChannelImage)
Handling of Image Sequences
Select and display all single channels of a multi channel image
count_channels(MultiChannelImage, Number)
for i := 1 to Number by 1
access_channel (MultiChannelImage, Image, i)
dev_display(Image,WindowHandle)
endfor
Aberration
n When looking (perpendicular) on a planar surface one would expect that
all pixels can be in focus at the same time
n But this is not correct: Either the center or the outer part of the image will
be completely in focus
n This effect is called aberration
n When measuring height
information with depth from
focus this kind of error causes
defects
n It is not difficult to determine
the aberration
n Based on this “calibration”
a correct measurement can
be applied
Aberration Calibration Setup
n A planar surface with a reasonable texture is used as the reference plane
n The camera is mounted perpendicular to this surface
n If needed, the angles can be determined by using the HALCON camera
calibration
n It is important that the same distance and camera setting are being used
that will be applied during the application
n Using depth from focus the “curvature of the surface”, i.e., the aberration
are determined
n The extracted reference surface is used to correct the later measurements
n For further use it is recommended to store the reference image to file
Aberration: Distance Reference
n The aberration can approximated by a paraboloidal function
n The approximation has the advantage of suppressing incorrect
measurements
n The parameters of the paraboloidal function can be used to generate a
reference image
n But subtracting the reference image from the depth measurement the
error caused by the aberration can be corrected
depth_from_focus (Image, Depth, Confidence, 'highpass', 'local')
threshold (Confidence, HighConf, 30, 255)
fit_surface_second_order (HighConf, Depth, 'tukey', 10, 2,
Alpha, Beta, Gamma, Delta, Epsilon, Zeta)
gen_image_surface_second_order (Aberration, 'real', Alpha, Beta,
Gamma, Delta, Epsilon, Zeta,
Height/2, Width/2, Width, Height)
3
Example: Aberration Volume Measurement
n In contrast to stereo the height information is not calibrated
n The values in the height image are the indexes of the input images
n To measure a real world height or a volume, the distance in between
these images must be known
n In the most easy case all images are taken with the same movement z
n So if two coordinates differ by an index values of n the real world
distance will be z x n, with the unit of z
n Besides this, the unit in x and y, i.e., the size of a pixel must be known
n Make sure that all dimensions are given in the same unit
n The volume can be determined with the operator area_center_gray
n The resulting value must be multiplied by x, y, and z
Volume Measurement Example: Tilted Metal Surface
Outlier points
in raw data
Example: SMD Component Example: Defect on a Metal Trace
本文档为【h013_05_halcon_dff】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。