1.difference算子检测region形状的差别,计算对象是两个region,不考虑region灰度值是否有差异;
2.sub_image算子是灰度值相减,计算对象是两幅图像,主要检测图像区别,和形状没有多大关系;
g' = (ga - gb) * Mult + Add
dev_update_off () dev_close_window () read_image (blackImage, 'E:/myhalcon/black.bmp') read_image (grayImage, 'E:/myhalcon/gray.bmp') dev_open_window_fit_image (grayImage, 0, 0, -1, -1, WindowHandle) set_window_param (WindowHandle, 'background_color', 'white') dev_clear_window () gen_rectangle1 (Rectangle, 100, 100, 300, 300) reduce_domain (blackImage, Rectangle, blackImageReduced) reduce_domain (grayImage, Rectangle, grayImageReduced) * 检查形状区别,不考虑区域灰度值 difference (blackImageReduced, grayImageReduced, RegionDifference) * 灰度值相减,不考虑形状 sub_image (blackImageReduced, grayImageReduced, ImageSub, 1, 200) gen_rectangle1 (Rectangle1, 200, 200, 400, 400) reduce_domain (blackImage, Rectangle1, blackImageReduced1) sub_image (blackImageReduced, blackImageReduced1, ImageSub, 1, 200)