码迷,mamicode.com
首页 > 其他好文 > 详细

STT-RAM取代DRAM内存

时间:2020-08-10 17:28:29      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:开发人员   使用   spin   技术   伸缩性   切换   https   半导体   自旋   

* 这个例程演示了如何用Gmm分类器用面积和圆度来对柑橘类水果惊醒识别和分类,以及显示识别到的2d特征空间


*This example program shows how to apply a general GMM
* classification to distinguish citrus fruits using the
* features ‘area‘ and ‘circularity‘. Additionally, the
* 2D feature space for the extracted fruits is visualized.
* 读取图像
read_image (Image, ‘color/citrus_fruits_01‘)
*获取图像指针
get_image_pointer1 (Image, Pointer, Type, Width, Height)
*关闭窗体
dev_close_window ()
*打开新窗体
dev_open_window (0, 0, Width, Height, ‘white‘, WindowHandle)
*设置窗体显示字体样式
set_display_font (WindowHandle, 12, ‘mono‘, ‘true‘, ‘false‘)
*设置填充样式
dev_set_draw (‘margin‘)
*设置线宽
dev_set_line_width (2)
*显示图像
dev_display (Image)
*关闭窗体更新
dev_update_window (‘off‘)
*关闭’pc‘更新
dev_update_pc (‘off‘)
*变量不更新
dev_update_var (‘off‘)
*
FeaturesArea := []
FeaturesCircularity := []
ClassName := [‘orange‘,‘lemon‘]
* 创建GMM分类器句柄
* Create a GMM classifier
create_class_gmm (2, 2, 1, ‘spherical‘, ‘normalization‘, 10, 42, GMMHandle)
* 分别加入训练样本
* Add training samples
for I := 1 to 4 by 1
    read_image (Image, ‘color/citrus_fruits_‘ + I$‘.2d‘)
    dev_display (Image)
    * ‘Add Samples‘添加样本
    get_regions (Image, SelectedRegions)
    *显示选择区域
    dev_display (SelectedRegions)
    *获取数量
    count_obj (SelectedRegions, NumberObjects)
    for J := 1 to NumberObjects by 1
        select_obj (SelectedRegions, ObjectSelected, J)
        *获取圆度和面积特征参数
        get_features (ObjectSelected, WindowHandle, Circularity, Area, RowRegionCenter, ColumnRegionCenter)
       *添加到数组
        FeaturesArea := [FeaturesArea,Area]
        FeaturesCircularity := [FeaturesCircularity,Circularity]
        FeatureVector := real([Circularity,Area])
       *前两副图像为橘子的训练图像
        if (I <= 2)
            *添加样本到橘子的分类ID
            add_sample_class_gmm (GMMHandle, FeatureVector, 0, 0)
            *显示信息
            disp_message (WindowHandle, ‘Add to Class:‘ + ClassName[0], ‘window‘, RowRegionCenter, ColumnRegionCenter - 100, ‘black‘, ‘true‘)
       *后两幅为柠檬的驯良图片
        else
             *添加样本到柠檬的分类ID
            add_sample_class_gmm (GMMHandle, FeatureVector, 1, 0)
             *显示信息
            disp_message (WindowHandle, ‘Add to Class:‘ + ClassName[1], ‘window‘, RowRegionCenter, ColumnRegionCenter - 100, ‘black‘, ‘true‘)
        endif
    endfor
    *右下角显示‘Press F5 to continue‘这个信息
    disp_continue_message (WindowHandle, ‘black‘, ‘true‘)
    stop ()
endfor
*清除窗体
dev_clear_window ()
* 分别显示橘子和柠檬的2D特征空间
* Visualize the feature space
visualize_2D_feature_space (Cross, Height, Width, WindowHandle, FeaturesArea[0:5], FeaturesCircularity[0:5], ‘dim gray‘, 18)
* ‘oranges‘, 40, 440
visualize_2D_feature_space (Cross, Height, Width, WindowHandle, FeaturesArea[6:11], FeaturesCircularity[6:11], ‘light gray‘, 18)
* ‘lemons‘, 70, 440
    *右下角显示‘Press F5 to continue‘这个信息
disp_continue_message (WindowHandle, ‘black‘, ‘true‘)
stop ()
* 前面是添加样本数据,现在是训练样本
* Train the classifier
train_class_gmm (GMMHandle, 100, 0.001, ‘training‘, 0.0001, Centers, Iter)
*
* Classify
for I := 1 to 15 by 1
    *读取图像
    read_image (Image, ‘color/citrus_fruits_‘ + I$‘.2d‘)
    *显示图像
    dev_display (Image)
    * ‘Classify Image‘, 10, 10
    get_regions (Image, SelectedRegions)
    *显示分割的区域
    dev_display (SelectedRegions)
    *数区域数量,一个一个识别
    count_obj (SelectedRegions, NumberObjects)
    for J := 1 to NumberObjects by 1
        *选择区域
        select_obj (SelectedRegions, ObjectSelected, J)
        *获取圆度和面积特征
        get_features (ObjectSelected, WindowHandle, Circularity, Area, RowRegionCenter, ColumnRegionCenter)
        FeaturesArea := [FeaturesArea,Area]
        FeaturesCircularity := [FeaturesCircularity,Circularity]
        FeatureVector := real([Circularity,Area])
        *执行飞来识别
        classify_class_gmm (GMMHandle, FeatureVector, 1, ClassID, ClassProb, Density, KSigmaProb)
        *显示识别到的物体信息
        disp_message (WindowHandle, ‘Class: ‘ + ClassName[ClassID], ‘window‘, RowRegionCenter, ColumnRegionCenter - 100, ‘black‘, ‘true‘)
        disp_message (WindowHandle, ‘KSigmaProb: ‘ + KSigmaProb, ‘window‘, RowRegionCenter + 30, ColumnRegionCenter - 100, ‘black‘, ‘true‘)
    endfor
    if (I != 15)
        disp_continue_message (WindowHandle, ‘black‘, ‘true‘)
        
    endif
    stop ()
endfor
* 清除句柄,释放内存
* Clear the classifier from memory
clear_class_gmm (GMMHandle)

STT-RAM取代DRAM内存

标签:开发人员   使用   spin   技术   伸缩性   切换   https   半导体   自旋   

原文地址:https://blog.51cto.com/14618340/2518639

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!