简介:
multilayer perceptron(MLP)即多层感知器。可用在颜色分类。
介绍:
WindowHandle (input_control) | Window identifier. | 窗体 |
Row1 (output_control) | Row index of the left upper corner. | 左上角的行坐标 |
Column1 (output_control) | Column index of the left upper corner. | 左上角的列坐标 |
Row2 (output_control) | Row index of the right lower corner. | 右下角的行坐标 |
Column2 (output_control) | Column index of the right lower corner. | 右下角的列坐标 |
NumInput (input_control) | Number of input variables (features) of the MLP. Default value: 20 Suggested values: 1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100 Restriction: NumInput >= 1 | MLP的输入特征数量 | ||
NumHidden (input_control) | Number of hidden units of the MLP. Default value: 10 Suggested values: 1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 150 Restriction: NumHidden >= 1 | MLP的隐藏特征数量 | ||
NumOutput (input_control) | Number of output variables (classes) of the MLP. Default value: 5 Suggested values: 1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 150 Restriction: NumOutput >= 1 | MLP的输出变量的数量 | ||
OutputFunction (input_control) | Type of the activation function in the output layer of the MLP.
| MLP的输出层中激活函数的类型 | ||
Preprocessing (input_control) | Type of preprocessing used to transform the feature vectors.
| 转换特征向量的预处理类型 | ||
NumComponents (input_control) | Preprocessing parameter: Number of transformed features (ignored for Preprocessing = 'none' and Preprocessing = 'normalization'). Default value: 10 Suggested values: 1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100 Restriction: NumComponents >= 1 | 预处理参数:转换后的特征数(Preprocessing = 'none'和Preprocessing = 'normalization'时忽略) | ||
RandSeed (input_control) | Seed value of the random number generator that is used to initialize the MLP with random values. Default value: 42 | 用于用随机值初始化MLP的随机数生成器的种子值 | ||
MLPHandle (output_control) | MLP handle. | 输出的MLP句柄 |
Image (input_object) | Training image. | 训练的图像 |
ClassRegions (input_object) | Regions of the classes to be trained. | 要训练的样本 |
MLPHandle (input_control, state is modified) | MLP handle. | MLP句柄 |
MLPHandle (input_control, state is modified) | MLP handle. | MLP句柄 |
MaxIterations (input_control) | Maximum number of iterations of the optimization algorithm. Default value: 200 Suggested values: 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300 | 优化算法的最大迭代次数 |
WeightTolerance (input_control) | Threshold for the difference of the weights of the MLP between two iterations of the optimization algorithm. | 阈值为MLP在两次迭代之间进行优化算法的权值之差 |
ErrorTolerance (input_control) | Threshold for the difference of the mean error of the MLP on the training data between two iterations of the optimization algorithm. Default value: 0.01 Suggested values: 1.0, 0.1, 0.01, 0.001, 0.0001, 0.00001 Restriction: ErrorTolerance >= 1.0e-8 | 阈值为MLP对训练数据的平均误差在两次迭代优化算法之间的差值 |
Error (output_control) | Mean error of the MLP on the training data. | MLP训练数据的平均误差 |
ErrorLog (output_control) | Mean error of the MLP on the training data as a function of the number of iterations of the optimization algorithm. | MLP训练数据的平均误差作为优化算法迭代次数的函数 |
MLPHandle (input_control) | MLP handle. | MLP句柄 |
FileName (input_control) | File name. File extension: .gmc | 文件路径 |
MLPHandle (input_control, state is modified) | MLP handle. | MLP句柄 |
FileName (input_control) | File name. File extension: .gmc | 文件路径 |
MLPHandle (output_control) | MLP handle. | MLP句柄 |
Image (input_object) | Input image. | 图像 |
ClassRegions (output_object) | Segmented classes. | 输出的检测结果 |
MLPHandle (input_control) | MLP handle. | MLP句柄 |
RejectionThreshold (input_control) | Threshold for the rejection of the classification. | 抛弃种类的阈值 |
使用:
- 搜集训练数据。
- 创建MLP,得到MLP的识别符(句柄)。然后采集数据、训练(保存、清除和读取)长久保存时可使用)。
- MLP识别后分类。注意:识别得到的结果和特征值的索引是反序的,即color数组和ClassRegions数组取到区域的对应是反序的。
read_image (Image, 'E:/照片/RGB.jpg')
*Red,Green,Blue,Dark(背景色)
color :=['R', 'G', 'B','D']
gen_empty_obj (Classes)
dev_set_draw ('margin')
for i := 1 to |color| by 1
dev_display (Image)
dev_display(Classes)
draw_rectangle1 (3600, Row1, Column1, Row2, Column2)
gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2)
concat_obj (Rectangle, Classes, Classes)
endfor
pathFile := 'E:/照片/color.mlp'
*创建分类器
create_class_mlp (3, 10, 4, 'softmax', 'normalization', 10, 42, MLPHandle)
*采集
add_samples_image_class_mlp (Image, Classes, MLPHandle)
*训练
train_class_mlp (MLPHandle, 100, 1, 0.01, Error, ErrorLog)
*保存
write_class_mlp (MLPHandle, pathFile)
*清除
clear_class_mlp (MLPHandle)
*读取
read_class_mlp (pathFile, MLPHandle)
*识别
classify_image_class_mlp (Image, ClassRegions, MLPHandle, 0.5)
count_obj (ClassRegions, Number)
for j := 1 to Number by 1
select_obj (ClassRegions, ObjectSelected, j)
connection (ObjectSelected, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 200, 99999)
area_center (SelectedRegions, Area, Row, Column)
for k:= 0 to |Area|-1 by 1
disp_message (3600, color[|color| - j], 'image', Row[k], Column[k], 'black', 'true')
endfor
endfor
![](https://i-blog.csdnimg.cn/blog_migrate/5a38cbafdaba47f867573ee6747f87ae.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/e24f52444b4acc7671355630412fdff8.png)