目录:百家号
Step 1: Create classifier创建分类器,例程使用基于MLP的分类器
Step 2: Add training samples to the classifier添加样例
Step 3: Train the classifier训练
Step 4: Classify new objects分类未知的物 ,分割图像,获取图像的形状特征,使用分类器分类图像,达到所属的类的编号。
?分类
Step 1: Create classifier创建分类器,例程使用基于MLP的分类器
create_class_mlp (6, 5, 3, 'softmax', 'normalization', 3, 42,MLPHandle)
Step 2: Add training samples to the classifier添加样例
添加已知类别的图像作为每个类的样例图,其中,每幅增加的图像都要进行处理:segment、add_samples
procedure segment (Image, Regions)简单的blob分析
*二值化
binary_threshold (Image, Region, 'max_separability', 'dark', UsedThreshold)
connection (Region, ConnectedRegions)
fill_up (ConnectedRegions, Regions)
return ()add_samples获取形状特征,并训练分类器。
procedure add_samples (Regions, MLPHandle, Class)
count_obj (Regions, Number)
for J := 1 to Number by 1select_obj (Regions, Region, J)get_features (Region, Features)add_sample_class_mlp (MLPHandle, Features, Class)
endfor
return ()get_features获取每个region的形状特征:circular、roudness、PSI并存入Features
procedure get_features (Region, Features)
select_obj (Region, SingleRegion, 1)
circularity (SingleRegion, Circularity)
roundness (SingleRegion, Distance, Sigma, Roundness, Sides)
moments_region_central_invar (SingleRegion, PSI1, PSI2, PSI3, PSI4)
Features := [Circularity,Roundness,PSI1,PSI2,PSI3,PSI4]
return ()
Step 3: Train the classifier训练
train_class_mlp (MLPHandle, 200, 1, 0.01, Error, ErrorLog)
Step 4: Classify new objects分类未知的物 ,分割图像,获取图像的形状特征,使用分类器分类图像,达到所属的类的编号。
分类
procedure classify (Regions, MLPHandle, Classes)
count_obj (Regions, Number)
Classes := []
for J := 1 to Number by 1
select_obj (Regions, Region, J)
get_features(Region, Features)
classify_class_mlp (MLPHandle, Features, 1, Class, Confidence)
Classes := [Classes,Class]
endfor
return ()