|
基于SVM的图像分割:
链接:https://pan.baidu.com/s/1xdnckcLcV0jhfsuEbL2Gfg 提取码:qixt
参考链接:https://pan.baidu.com/s/1XQmrm-26SCSnPOZPHplqAQ
- dev_update_window ('off')
- dev_set_draw ('margin')
- dev_update_var ('off')
- dev_update_pc ('off')
- read_image (Image, './plastic_mesh/plastic_mesh_01.png')
- get_image_size (Image, Width, Height)
- gen_rectangle1 (Rectangle, 10, 10, Height / 2 - 11, Width / 2 - 11)
- * Create the SVM classifier with the novelty detection mode.
- create_class_svm (5, 'rbf', 0.01, 0.0005, 1, 'novelty-detection', 'normalization', 5, SVMHandle)
- for J := 1 to 5 by 1
- read_image (Image, './plastic_mesh/plastic_mesh_0' + J +'.png')
- zoom_image_factor (Image, ImageZoomed, 0.5, 0.5, 'constant')
- gen_texture_image (ImageZoomed, ImageTexture)
- * 增加训练样本
- add_samples_image_class_svm (ImageTexture, Rectangle, SVMHandle)
- endfor
- dev_display (ImageZoomed)
- * 训练
- train_class_svm (SVMHandle, 0.001, 'default')
- * 降维
- reduce_class_svm (SVMHandle, 'bottom_up', 2, 0.001, SVMHandleReduced)
- * Now detect errors in the plastic meshes.
- for J := 1 to 14 by 1
- read_image (Image, './plastic_mesh/plastic_mesh_0' + J +'.png')
- zoom_image_factor (Image, ImageZoomed, 0.5, 0.5, 'constant')
- gen_texture_image (ImageZoomed, ImageTexture)
- reduce_domain (ImageTexture, Rectangle, ImageTextureReduced)
- * SVM分类器
- classify_image_class_svm (ImageTextureReduced, Errors, SVMHandleReduced)
- * 形态学处理
- opening_circle (Errors, ErrorsOpening, 3.5)
- closing_circle (ErrorsOpening, ErrorsClosing, 10.5)
- connection (ErrorsClosing, ErrorsConnected)
- select_shape (ErrorsConnected, FinalErrors, 'area', 'and', 300, 1000000)
- count_obj (FinalErrors, NumErrors)
- dev_set_color ('red')
- dev_set_line_width (3)
- dev_display (FinalErrors)
- stop ()
- endfor
- clear_class_svm (SVMHandle)
- clear_class_svm (SVMHandleReduced)
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|