Sunday, 4 August 2013

Gesture Recognition using Neural Network in MATLAB Code Part 3

preprocess_gesture.m 

If you have not seen previous post then please go through it first then come back   go to Previous Part


Create a Menu

clc
F = MENU('Choose a database set','Test Set','Train Set'); 
if F==1
K = MENU('Choose a file','Test O');

FOR TESTING A DATASET

if K == 1
    loop=5 
    for i=1:loop 
       string = ['test\O\' num2str(i) '.tif']; 
       Rimages{i} = imread(string); 
    end 

 end 
 end 
end;

FOR TRAINING


if F==2 
    loop=3    %Set loop to 3. All train sets have 3 images 
    L = MENU('Choose a file','Train O'); 
if L == 1 

    for i=1:loop 
    string = ['train\O\' num2str(i) '.tif']; 
    Rimages{i} = imread(string); 
    end
end 
end 

Now do what I am doing here


T{i}=imresize(Timages{i},[150,140]); 

    x = [0 -1 1];                               
    y = [0 1 -1]';

dx{i} = convn(T{i},x,'same');
dy{i} = convn(T{i},y,'same');
gradient{i} = dy{i} ./dx{i};
theta{i} = atan(gradient{i});
cl{i}= im2col(theta{i},[1 1],'distinct');
 N{i} = (cl{i}*180)/3.14159265359; .
c1{i}=(N{i}>0)&(N{i}<10 div="" nbsp="">
    s1{i}=sum(c1{i}); 

    c2{i}=(N{i}>10.0001)&(N{i}<20 div="" nbsp="">
    s2{i}=sum(c2{i}); 

    c3{i}=(N{i}>20.0001)&(N{i}<30 div="" nbsp="">
    sum(c3{i}); 
    s3{i}=sum(c3{i}); 

    c4{i}=(N{i}>30.0001)&(N{i}<40 div="" nbsp="">
    sum(c4{i}); 
    s4{i}=sum(c4{i}); 

    c5{i}=(N{i}>40.0001)&(N{i}<50 div="" nbsp="">
    sum(c5{i}); 
    s5{i}=sum(c5{i}); 

    c6{i}=(N{i}>50.0001)&(N{i}<60 div="" nbsp="">
    sum(c6{i}); 
    s6{i}=sum(c6{i}); 

    c7{i}=(N{i}>60.0001)&(N{i}<70 div="" nbsp="">
    sum(c7{i}); 
    s7{i}=sum(c7{i}); 

    c8{i}=(N{i}>70.0001)&(N{i}<80 div="" nbsp="">
    sum(c8{i}); 
    s8{i}=sum(c8{i}); 

    c9{i}=(N{i}>80.0001)&(N{i}<90 div="" nbsp="">
    sum(c9{i}); 
    s9{i}=sum(c9{i}); 

    c10{i}=(N{i}>90.0001)&(N{i}<100 div="" nbsp="">
    sum(c10{i}); 
    s10{i}=sum(c10{i}); 

    c11{i}=(N{i}>-89.9)&(N{i}<-80 div="" nbsp="">
    sum(c11{i}); 
    s11{i}=sum(c11{i}); 
    c12{i}=(N{i}>-80.0001)&(N{i}<-70 div="" nbsp="">
    sum(c12{i}); 
    s12{i}=sum(c12{i}); 

    c13{i}=(N{i}>-70.0001)&(N{i}<-60 div="" nbsp="">
    sum(c13{i}); 
    s13{i}=sum(c13{i}); 

    c14{i}=(N{i}>-60.0001)&(N{i}<-50 div="" nbsp="">
    sum(c14{i}); 
    s14{i}=sum(c14{i}); 

    c15{i}=(N{i}>-50.0001)&(N{i}<-40 div="" nbsp="">
    sum(c15{i}); 
    s15{i}=sum(c15{i}); 

    c16{i}=(N{i}>-40.0001)&(N{i}<-30 div="" nbsp="">
    sum(c16{i}); 
    s16{i}=sum(c16{i}); 

    c17{i}=(N{i}>-30.0001)&(N{i}<-20 div="" nbsp="">
    sum(c17{i}); 
    s17{i}=sum(c17{i}); 

    c18{i}=(N{i}>-20.0001)&(N{i}<-10 div="" nbsp="">
    sum(c18{i}); 
    s18{i}=sum(c18{i}); 

    c19{i}=(N{i}>-10.0001)&(N{i}<-0 .0001="" div="" nbsp="">
    sum(c19{i}); 
    s19{i}=sum(c19{i}); 

    D{i}= [s1{i} s2{i} s3{i} s4{i} s5{i} s6{i} s7{i} s8{i} s9{i} s10{i} s11{i} s12{i} s13{i} s14{i} s15{i} s16{i} s17{i} s18{i} s19{i}]; 

close(w);

Guys thanks for visiting my blog,Have fun :)


This is the end of gesture recognition


Please LIKE and COMMENT...


9 comments:

  1. The code on gesture control-neural network is awesome but can the same be done even on a music player??? can you tell me which part of your code has to modified in order to achieve it ??

    ReplyDelete
    Replies
    1. Okey... I will try to post an article on this ..... :)

      Delete
    2. thank yo so much :)

      Delete
    3. hey thanks a lot for uploading information on music control its so nice of you to have replied to just an anonymous post.Truly speaking I donno matlab much so I think I'll use this information and complete my project successfully,And surely I'll keep you updated with my comments here regarding my project.

      Thank you so much one again :)

      Delete
  2. can u tell me, the code for gender identification from face images??

    ReplyDelete
  3. hey i wanted to know is there any issue in the syntax? as c1{i}=(N{i}>0)&(N{i}<10 div="" nbsp="">
    s1{i}=sum(c1{i}); is issuing an error. pls help? reply asap.

    ReplyDelete
  4. the code doesn't seem to work ..y? .. and also where should i save the pics for training

    ReplyDelete
  5. i want develop this project in R2013b but it can work properly please help me how to implement please

    ReplyDelete