read_image (Image, 'data/board')
rgb1_to_gray (Image, GrayImage)
threshold (GrayImage, Region, 100, 255)
gen_image_proto (GrayImage, ImageCleared, 0)
erosion_circle (Region, RegionErosion, 7.5)
erosion_circle (RegionErosion, RegionErosion2, 6.5)
dev_clear_window ()
dev_display (RegionErosion2)
*膨胀操作
dilation_circle (RegionErosion2, RegionDilation, 23.5)
dev_clear_window ()
dev_display (RegionDilation)
*读取待检测的图像
read_image (Image,'data/board')
*将图像转换为单通道的灰度图像
rgb1_to_gray(Image, GrayImage)
*创建矩形区域
gen_rectangle1 (Rectangle, 259, 87, 957, 909)
*进行裁剪,将感兴趣区域单独提取出来
reduce_domain (GrayImage, Rectangle, ImageReduced)
*使用阈值处理将灰度值于设定的像素选取出来
threshold(ImageReduced,Light,85,255)
*创建圆形结构元素,用于开运算
gen_circle(StructElement,6,6,7)
*进行开运算去除背景中的杂点
opening(Light,StructElement,Large)
dev_clear_window ()
dev_display (Large)
read_image (Image,'data/shapes')
*将图像进行通道分解,分别转换为三个通道的RGB图像
decompose3 (Image, Red, Green, Blue)
*使用颜色转换将RGB三个通道图像转化为HSV通道的图像
trans_from_rgb (Red, Green, Blue, Hue, Saturation, Intensity, 'hsv')
*对饱和度通道的图像进行阈值处理
threshold (Saturation, Regions, 180, 255)
*创建圆形结构元素用于闭运算
gen_circle(StructElement,10,10,10)
*对图像中较亮的区域进行闭运算处理,填补了各自轮廓中的小空隙
closing(Regions,StructElement,Large)
dev_clear_window ()
dev_display (Large)
read_image (Image,'data/board')
rgb1_to_gray(Image, GrayImage)
gen_rectangle1 (Rectangle, 259, 87, 957, 909)
reduce_domain (GrayImage, Rectangle, ImageReduced)
threshold(ImageReduced,Light,85,255)
gen_circle(StructElement,6,6,7)
*清理显示窗口,以便显示结果
dev_clear_window ()
*进行顶帽运算,得到了开运算中移除的局部像素并高亮显示
top_hat (Light, StructElement, RegionTopHat)
dev_clear_window ()
dev_display (RegionTopHat)
read_image (Image,'data/shapes')
decompose3 (Image, Red, Green, Blue)
trans_from_rgb (Red, Green, Blue, Hue, Saturation, Intensity, 'hsv')
threshold (Saturation, Regions, 180, 255)
gen_circle(StructElement,10,10,10)
*清理显示窗口,以便显示结果
dev_clear_window ()
*清理显示窗口,以便显示结果
bottom_hat (Regions, StructElement, RegionBottomHat)
dev_clear_window ()
dev_display (RegionBottomHat)
*读取一幅光照不均匀的亮背景图像,这里选取的是一幅彩色图像
read_image (Image,'data/shapes')
*变换之前转为灰度图像
rgb1_to_gray (Image, GrayImage)
*将图像通过阈值处理转化为二值化图像。
threshold (GrayImage, Regions, 145, 255)
*创建一个结构元素,这里创建的是一个圆形
gen_circle(StructElement,10,10,100)
*清空窗口便于显示结果
dev_clear_window ()
*进行底帽操作,提取出较暗区域
bottom_hat (Regions, StructElement, RegionBottomHat)
*将较暗区域从原图中提取出来
reduce_domain (Image, RegionBottomHat, ImageReduced)
dev_clear_window ()
dev_display (ImageReduced)
read_image (ImageColor, 'data/village.jpg')
*将原始图像转换为灰度图像作为形态学处理的输入
rgb1_to_gray (ImageColor, Image)
*进行灰度图像腐蚀操作
gray_erosion_shape (Image, ImageMin, 11, 11, 'octagon')
*进行灰度图像膨胀操作
gray_dilation_shape (Image, ImageMax, 11, 11, 'octagon')
*进行灰度图像开运算操作
gray_opening_shape (Image, ImageOpening, 7, 7, 'octagon')
*进行灰度图像闭运算操作
gray_closing_shape (Image, ImageClosing, 7, 7, 'octagon')