请选择 进入手机版 | 继续访问电脑版

Hello Mat

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 399|回复: 0

MLP下的图像分类

[复制链接]

754

主题

893

帖子

2万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
29864
发表于 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
回复

使用道具 举报

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

本版积分规则


Python|Opencv|MATLAB|Halcom.cn  

GMT+8, 2019-10-19 17:31 , Processed in 0.125853 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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