dev_close_window ()
dev_update_off ()
read_image (baseimage, 'blister/blister_reference')
get_image_size (baseimage, width, height)
dev_open_window_fit_image (baseimage, 0, 0, -1, -1, windowhandle)
set_display_font (windowhandle, 16, 'mono', 'true', 'false')
dev_set_draw ('margin')
dev_set_line_width (3)
* 1.分離通道》二值化得到外部區域》仿射變換得到基準》生成藥丸區域
* 2.讀取》仿射變換位置到基準》獲取藥丸位置》遍歷藥丸二值化判斷是否有無放錯
* 分離通道
access_channel (baseimage, image, 1)
* 得到外部區域
threshold (image, region, 60, 255)
connection (region, connectedregions)
select_shape (connectedregions, selectedregions, 'area', 'and', 50000, 9999999)
shape_trans (selectedregions, regiontrans, 'convex')
* 仿射變換
orientation_region (regiontrans, phi)
area_center (regiontrans, area, row, column)
vector_angle_to_rigid (row, column, phi, row, column, 0, hommat2d)
affine_trans_image (image, base_image, hommat2d, 'constant', 'false')
* 生成藥丸區域
gen_empty_obj (base_inner_cp_region)
cp_row_number := 5
cp_column_number := 3
for index := 1 to cp_row_number by 1
* 外迴圈控制row 內迴圈控制column
row := 85+(index-1)*71
for index1 := 1 to cp_column_number by 1
column := 160+(index1-1)*151
gen_rectangle2 (rectangle, row, column, 0, 67, 30)
concat_obj (base_inner_cp_region, rectangle, base_inner_cp_region)
endfor
endfor
union1 (base_inner_cp_region, union_base_inner_cp_region)
affine_trans_region (regiontrans, regionaffinetrans, hommat2d, 'nearest_neighbor')
orientation_region (regionaffinetrans, base_phi)
area_center (regionaffinetrans, area1, base_row, base_column)
image_count := 6
for index2 := 1 to image_count by 1
read_image (image1, 'blister/blister_'+index2$'02')
decompose3 (image1, imager, imageg, imageb)
threshold (imageb, region1, 200, 255)
connection (region1, connectedregions1)
select_shape (connectedregions1, selectedregions1, 'area', 'and', 50000, 9999999)
fill_up (selectedregions1, regionfillup)
shape_trans (regionfillup, regiontrans1, 'convex')
orientation_region (regiontrans1, now_phi)
area_center (regiontrans1, area2, now_row, now_column)
vector_angle_to_rigid (now_row, now_column, now_phi, base_row, base_column, base_phi, hommat2d1)
affine_trans_image (image1, show_image, hommat2d1, 'constant', 'false')
affine_trans_image (imageb, imageaffinetrans, hommat2d1, 'constant', 'false')
reduce_domain (imageaffinetrans, union_base_inner_cp_region, image_reduce_out_imageb)
* 二值化得到產品
mean_image (image_reduce_out_imageb, mean_imageb, 15, 15)
dyn_threshold (image_reduce_out_imageb, mean_imageb, regiondynthresh, 10, 'dark')
fill_up (regiondynthresh, regionfillup1)
opening_circle (regionfillup1, regionopening, 15)
* 遍歷拿到每乙個產品判斷灰度值
gen_empty_obj (is_null)
gen_empty_obj (is_error)
count_obj (base_inner_cp_region, number)
for index3 := 1 to number by 1
select_obj (base_inner_cp_region, select_region, index3)
intersection (select_region, regionopening, intersection_out_image)
min_max_gray (intersection_out_image, image_reduce_out_imageb, 0, min, max, range)
area_center (intersection_out_image, area3, row1, column1)
* 判斷是否為空
if(area3>0)
if (area3<3700 or min<60)
concat_obj (is_error, intersection_out_image, is_error)
disp_message (windowhandle, 'ng', 'window', 12, 600, 'red', 'true')
endif
else
concat_obj (is_null, select_region, is_null)
disp_message (windowhandle, 'ng', 'window', 12, 600, 'red', 'true')
endif
endfor
* 顯示
dev_display (show_image)
dev_set_color ('green')
dev_display (regionopening)
count_obj (is_null, is_null_num)
count_obj (is_error, is_error_num)
dev_set_color ('red')
dev_display (is_null)
dev_display (is_error)
stop ()
endfor
Halcon一維碼查詢
一 影象預處理和條碼增強 對比度太低 scale image 或使用外部程式scale image range 增強影象的對比度。影象模糊 emphasize銳化影象,使條碼看起來更清晰。深色背景上讀取淺色條碼 invert image反轉影象。二 解碼涉及的主要運算元 read image 讀圖 ...
奈米小藥丸穿透癌細胞 治癌
許多癌症患者到了 晚期 只能等死。這時求神拜佛也不靈了。世界衛生組織報告顯示,2008 年全世界約有 1,270 萬新增癌症患者,760萬死於癌症。尤其在發展中國家,每年癌症新增例數高達 56 癌症患者越來越多。說白了,國人與外國人都怕 癌症 實際上,癌症是一種基因病,癌細胞基因快速 複製 致使癌細...
HALCON常用運算元(HALCON13 0)
halcon常用運算元 halcon13.0 chapter 9 develop chapter 10 file 10.1 images example 1 讀一副影象 read image image,mreut 2 將3幅影象讀入影象陣列 read image images,ic0 ic1 ic...