?????????surface_scratch.hdev
???????????????????t?????????????????????滮??
???????????????????????????????????????????д???
*surface_scratch.hdev:extraction of surface scratches via local thresholding and morphological post-processing*
dev_close_window()
dev_update_window(‘off’)
*****
*step: acquire image                  //?????
*****
read_image(Image??’surface_scratch’)  //?????????’surface_scratch’????
get_image_size(Image??Width??Height)    //????????磺?????
//?????????0??0????????????????????????Width??Width??????????WindowID
dev_open_window_fit_image(Image??0??0??Width??Width??WindowID)
//?????????????????????????С????????б
set_display_font(WindowID??12??’Courier’??’true’??’false’)
dev_set_draw(‘margin’)              //????????????????’margin’ or ‘fill’
dev_set_line_width(4)                //?????????????????????fill?Ч????????
dev_display(Image)                   //?????
disp_continue_message(WindowID??’black’??’true’)    //????????????????????F5???????
stop()
*****
*step: segment image
*****
*-> using a local threshold
mean_image(Image??ImageMean??7??7)                      //??7×7???????????о?????
dyn_threshold(Image??ImageMean??DarkPixels??5??’dark’)  //???????????????????
*->extract connected components
connection(DarkPixels??ConnectedRegions)    //????????????????
dev_set_colored(12)                        //???????????????????
dev_display(ConnectedRegions)              //??????
disp_continue_message(WindowID??’black’??’true’)//???????????????????
stop()
*****
*step: process regions
*****
*->select large regions
select_shape(ConnectedRegions??SelsectedRegions??’area’??’and’??10??1000)    //?????????????????????????????10??10000???????
dev_display(Image)                      //?????
dev_display(SelectedRegions)            //???????????
disp_continue_message(WindowID??’black’??’true’)    //???????????????????
stop()
*->visualize fractioned scratch
open_zoom_window(0??round(Width/2)??2??303??137??496??3??WindowHandleZoom)
dev_set_color(‘blue’)            //?????????????????????????dev_set_colored????
dev_display(Image)                //?????
dev_display(SelectedRegions)      //?????е??????
disp_continue_message(WindowID??’black’??’true’)    //?????????????
stop()
*->merge fractioned scratches via morphology
union1(SelectedRegions??RegionUnion)             //???????????
dilation_circle(RegionUnion??RegionDilation??3.5) //?e?3.5 ?????????????
dev_display(Image)                              //?????
dev_display(RegionDilation)                     //??????????????
disp_continue_message(WindowID??’black’??’true’)//?????????????
stop()
skeleton(RegionDialtion??Skeleton)      //????????????????????surface_scratch.hdev
connection(Skeleton??Errors)            //?????????????????????????
dev_set_colored(12)                    //???????
dev_display(Image)                     //?????
dev_display(Errors)                    //??????????
disp_continue_message(WindowID??’black’??’true’)    //?????????????
stop()
*->distinguish small and large scratches
close_zoom_window(WindowHandleZoom??Width??Height)       //??????????
select_shape(Errors??Scratches??’area’??’and’??50??10000)//????????????50??10000?????????
select_shape(Errors??Dots??’area’??’and’??1??50)         //????????????1??50 ???????
dev_display(Image)                    //?????
dev_set_color(‘red’)                 //??????????????????
dev_display(Scratches)                //????????????????????
dev_set_color(‘blue’)               //?????????????????
dev_display(Dots)                     //????????????????????