图像清晰度计算

* This example shows how to measure the sharpness of an image using
* four characteristic quantities. These are the Blurriness (Auto-Correlation),
* the  Image Difference of local neighborhoods (Difference), the Gradient
* and the range of Frequencies in an image (Band pass).
* These quantities are calculated for a sequence of images, which depict
* one object in different focal points. At one point the lense is in the right
* focus, which is also stressed by the peak of the four quantity functions
* (in the mid of all four functions).
* 
dev_update_off ()
dev_close_window ()
* 
read_image (Image, 'pcb_focus/pcb_focus_telecentric_001')
get_image_size (Image, Width, Height)
dev_close_window ()
OWFMaxExtent := 600
dev_open_window_fit_size (0, 0, Width, Height, OWFMaxExtent, OWFMaxExtent, WindowHandle)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
* 
* Variables to tune sharpness measurement
Subsampling := 3
LowerBandPass := 0.1
UpperBandPass := 0.4
OffsetRow := 2
OffsetCol := 2
* 
* Compute the four quantities of sharpness
FocusAutoCorrelationTuple := []
FocusBandpassTuple := []
FocusGradientTuple := []
FocusDifferenceTuple := []
NumImages := 121
for I := 1 to NumImages by 1
    read_image (Image, 'pcb_focus/pcb_focus_telecentric_' + I$'.3d')
    set_system ('flush_graphic', 'false')
    dev_display (Image)
    disp_message (WindowHandle, 'Measuring Sharpness of Image: ' + I$'03', 'window', -1, -1, 'white', 'false')
    set_system ('flush_graphic', 'true')
    disp_line (WindowHandle, -101, -101, -99, -99)
    action_calculate_auto_correlation (Image, Subsampling, FocusAutoCorrelation)
    FocusAutoCorrelationTuple := [FocusAutoCorrelationTuple,FocusAutoCorrelation]
    action_calculate_bandpass (Image, LowerBandPass, UpperBandPass, Subsampling, FocusBandpass)
    FocusBandpassTuple := [FocusBandpassTuple,FocusBandpass]
    action_calculate_edge_gradient (Image, FocusGradient)
    FocusGradientTuple := [FocusGradientTuple,FocusGradient]
    action_calculate_image_difference (Image, OffsetRow, OffsetCol, Height, Width, FocusDifference)
    FocusDifferenceTuple := [FocusDifferenceTuple,FocusDifference]
endfor
* 
* Display the four sharpness functions
dev_display (Image)
dev_set_line_width (2)
disp_message (WindowHandle, 'Sharpness functions of an image sequence' + '\ntaken with varying focus adjustment', 'window', -1, -1, 'white', 'false')
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
Colors := ['blue','cyan','green','red']
disp_message (WindowHandle, ['Gradient','Difference','Bandpass','Auto Correlation'], 'window', 72, 72, Colors, 'false')
plot_tuple (WindowHandle, [1:NumImages], [FocusGradientTuple,FocusDifferenceTuple,FocusBandpassTuple,FocusAutoCorrelationTuple], 'Image', '', Colors, 'margin_bottom', 70)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

胖子工作室

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值