图像识别基于ksvd字典学习之人脸表情识别matlab源码

Posted Matlab走起

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了图像识别基于ksvd字典学习之人脸表情识别matlab源码相关的知识,希望对你有一定的参考价值。

 

  1. %
    %
    % Main Program of KSVD-NN based facial expression recognition.
    
    clear
    datadim='37x30';
    %datadim='50x40';
    %datadim='gabor_all';
    testmethod='unfamiliar';
     
     
    % prepare image data
    [data,label] = PrepareData(datadim,testmethod,9);
     
    % direct nearest neighbor classification
    testresult = nearestNeighbor( data.train , label.train , data.test );
    rate = length( find( ( testresult - label.test ) == 0 ) ) / length(label.test);
    clear testresult;
    fprintf('\\n Direct nearest neighbot on pixel values: rec rate: %f \\n',rate);
     
     
    % training process using KSVD
    param.L = 12;
    param.K = 90;
    param.numIteration = 20;
    param.errorFlag = 0;
    param.preserveDCAtom = 0;
    param.InitializationMethod = 'DataElements';
    param.displayProgress = 1;
    disp('Starting to  train the dictionary');
    tt=cputime;
    [Dictionary,KSVDout]  = KSVD(data.train,param);
    fprintf('\\ntime of K-SVD: %f\\n\\n' , cputime - tt);
    %I=showdict(Dictionary,[37,30],10,8,'lines') ;
    %imshow(I);
    %KSVDout.CoefMatrix = full( KSVDout.CoefMatrix );
    tt=cputime;
    % Using OMP to find the sparse coefficients for test samples
    coeftest = OMP(Dictionary,data.test,param.L);
    %coeftest = full( coeftest );
     
    % nearest neighbor classification
    testresult = nearestNeighbor( KSVDout.CoefMatrix , label.train , coeftest );
    fprintf('\\ntime of testing: %f\\n\\n' , cputime - tt);
    rate = length( find( ( testresult - label.test ) == 0 ) ) / length(label.test);
     
    fprintf('\\n The result when image dimension: %s    test-method: %s \\n' , datadim, testmethod );
    fprintf(' L(sparsity of coef) = %d, K(number of atoms) = %d : recognition rate: %f \\n\\n\\n',param.L , param.K , rate);
     
    % direct pixal values
    testresult = nearestNeighbor( data.train , label.train , data.test );
    rate = length( find( ( testresult - label.test ) == 0 ) ) / length(label.test);

    完整代码或者仿真咨询添加QQ1575304183

以上是关于图像识别基于ksvd字典学习之人脸表情识别matlab源码的主要内容,如果未能解决你的问题,请参考以下文章

图像去噪基于KSVD实现图像去噪matlab源码

图像识别基于模板匹配之人脸表情识别matlab源码含GUI

人脸表情识别基于matlab GUI CNN人脸表情识别含Matlab源码 787期

图像识别基于LBP+LPQ算法融合人脸表情识别matlab源码

人脸识别门禁系统Java源代码

基于深度学习的人脸表情识别实现