Hello Mat

 找回密码
 立即注册
查看: 9803|回复: 1

MLP下的图像分类

[复制链接]

1323

主题

1551

帖子

0

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22647
发表于 2019-7-22 22:18:53 | 显示全部楼层 |阅读模式
MLP下的图像分类:
  1. * The object of this example is to classify different kinds of wood according to their surface texture.
  2. dev_update_off()
  3. dev_set_draw('margin')
  4. HalconImages:='C:\\Users\\Public\\Documents\\MVTec\\HALCON-12.0\\examples\\images'
  5. ImagePath := '/wood/'
  6. try
  7.     read_image (Image, HalconImages + ImagePath + 'apple/apple_01')
  8.     ReadPath := HalconImages + ImagePath
  9. catch (Exception)
  10. endtry
  11. read_image (Image, ImagePath + 'apple/apple_01')
  12. get_image_pointer1 (Image, Pointer, Type, Width, Height)
  13. dev_close_window ()
  14. dev_open_window_fit_image (Image, 0, 0, Width, Height, WindowID)
  15. set_display_font (WindowID, 22, 'mono', 'true', 'false')
  16. dev_display (Image)
  17. dev_update_off ()
  18. * Now the different wood classes are specified.
  19. Classes := ['apple','beech','cherry','maple','oak','walnut']
  20. gen_features (Image, FeatureVector)
  21. NumFeatures := |FeatureVector|
  22. NumClasses := |Classes|
  23. NumHidden := 15
  24. create_class_mlp (NumFeatures, NumHidden, NumClasses, 'softmax', 'normalization', 10, 42, MLPHandle)
  25. for CorrectClassID := 0 to NumClasses - 1 by 1
  26.     list_files (ReadPath + Classes[CorrectClassID], 'files', Files)
  27.     for k := 0 to |Files| - 1 by 2
  28.         read_image (Image, Files[k])
  29.         dev_display (Image)
  30.         gen_features (Image, FeatureVector)
  31.         add_sample_class_mlp (MLPHandle, FeatureVector, CorrectClassID)
  32.     endfor
  33. endfor
  34. train_class_mlp (MLPHandle, 200, 1, 0.0001, Error, ErrorLog)
  35. write_class_mlp (MLPHandle, 'classify_wood.gmc')
  36. disp_message (WindowID, 'Training of wood textures completed\nPress \'Run\' to continue', 'window', -1, -1, 'black', 'true')
  37. stop ()
  38. *
  39. read_image (Image, ImagePath + 'apple/apple_02')
  40. gen_features (Image, FeatureVector)
  41. classify_class_mlp (MLPHandle, FeatureVector, 1, FoundClassIDs, Confidence)
  42. *
  43. clear_class_mlp (MLPHandle)
复制代码

特征选取函数如下:
(1)分类器特征提取 http://halcom.cn/forum.php?mod=viewthread&tid=33506&extra=page%3D1



算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

0

主题

14

帖子

1

金钱

新手上路

Rank: 1

积分
12
发表于 2020-7-1 10:30:37 | 显示全部楼层
全能大神么,膜拜
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-11-22 16:19 , Processed in 0.210696 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表