read_image (Image1, 'alpha1')
*均值滤波
mean_image(Image1, ImageMean, 21, 21)
*局部阈值分割
dyn_threshold(Image1, ImageMean, RegionDynThresh, 15, 'dark')
read_image (Image1, 'alpha1')
*中值滤波,将文字滤除
median_image(Image1, ImageMedian, 'circle', 10.5, 'mirrored')
*局部阈值分割
dyn_threshold(Image1, ImageMedian, RegionDynThresh, 15, 'dark')
read_image (Image1, 'alpha1')
*一般是调整AbsThreshold
var_threshold(Image1, Region, 15, 15, 1.01, 15, 'dark')
read_image (Image1, 'alpha1')
median_image(Image1, ImageMedian, 'circle', 3, 'mirrored')
*局部均值和标准偏差分析阈值分割
var_threshold(ImageMedian, Region, 15, 15, 0.2, 2, 'dark')
* This example program shows the usage of var_threshold to threshold an image
* by local mean and standard deviation analysis.
*
* With var_threshold, it's possible to select the pixels of the input Image which
* have a high local standard deviation (for a positive StdDevScale),
* or a low local standard deviation (for a negative StdDevScale)
* and are locally bright or dark, according to LightDark.
* Thus, it is possible to segment regions on inhomogeneous, noisy,
* or unevenly illuminated backgrounds.
dev_close_window ()
dev_update_off ()
*
* Read all images in the directory 'label'
* and select all images that end with 'label_', three arbitrary characters,
* and then the string 'png'.
list_image_files ('label', 'default', [], ImageFiles)
ImageFiles1 := regexp_select(ImageFiles,'label_...png$')
*
* Open a window to display the results.
read_image (Image, ImageFiles1[0])
get_image_size (Image, Width, Height)
dev_open_window_fit_size (0, 0, Width, Height, -1, -1, WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
*
* Loop over all images.
for Index := 0 to |ImageFiles1| - 1 by 1
read_image (Image, ImageFiles1[Index])
* Threshold the image.
var_threshold (Image, Region, 15, 15, 1.01, 40, 'dark')
* Select regions of particular height and size.
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, ['height','area'], 'and', [20,100], [100,400])
* Display the results
dev_display (Image)
dev_display (SelectedRegions)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
endfor
disp_end_of_program_message (WindowHandle, 'black', 'true')