Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. function [outputPicture] = smoothMe (inputPicture)
  2. G=fspecial('gaussian', [10 10],3); %Create Gaussian mask
  3. outputPicture = conv2(inputPicture,G,'same'); %Convolve the grayscale image with Gaussian filters
  4. end
  5. Ex1 :
  6.  
  7. function [H_outputPicture, V_outputPicture] = sobelOperators(inputPicture)
  8. %Convolve the grayscale image with horizontal Sobel filters
  9. H_outputPicture = conv2(inputPicture, [1 2 1; 0 0 0; -1 -2 -1])
  10. %Convolve the grayscale image with vertical Sobel filters
  11. V_outputPicture = conv2(inputPicture, [1 0 -1; 2 0 -2; 1 0 -1])
  12. end
  13. Ex2 :
  14.  
  15. function[ match ] = recogniseFace( Unknown_face, Train_face )
  16. %Training
  17. [U,S,D]=svds(Train_Face, 30) %First 30 Eigen vectors
  18. 1TFaces= U'*Train_Face %low dimension Training Face with 20 dimension
  19. %Prediction
  20. 1UnknownFace = U'*Unknown_Face
  21. EuclideanDist=sqrt(sum((1TFaces-repmat(1UnknownFace,[1 34])).^2))
  22. [match_score, match]=min(EuclideanDist);
  23. end
  24. Ex3 :
  25.  
  26. function [ ranks, frequency ] = querystring( query, Tf, uniqueCell )
  27. queryCell = strsplit(query)';
  28. number_of_documents=size(Tf,2);
  29. for i = 1 : size(queryCell,1)
  30. frequency(i,1:number_of_documents)= Tf(find(strcmp(uniqueCell,queryCell(i))),:);
  31. end
  32. frequency=sum(frequency);
  33. [frequency, ranks]=sort(frequency,'descend');
  34. end
  35. Ex4
  36.  
  37. function [tfidfM] = tfidf(Tf)
  38. %Input Tf is the term frequency matrix (importance of a document to a term)
  39. %N is the total number of documents in the corpus
  40. N = size(Tf, 2); %number of columns
  41. n = sum (Tf > 0, 2); %n(t) is the number of the documents in the corpus that contains term t
  42. idf = log(N./(1+n)); %Inverse Document Frequency
  43. %Term frequency inverse document frequency Matrix
  44. tfidfM = Tf.*repmat(idf,[1 size(Tf, 2)]);
  45. end
  46. Ex5
  47. function [ s ] = kalmanfilter( s )
  48. %Kalman filter store state in variable s
  49. %s is a structure with field
  50. %s.x = state variables
  51. %s.F = transformation matrix
  52. %s.P = covariance of variables (how to initialize? with R)
  53. %s.R = covariance of sensor (Radar) / sampling error
  54. %s.z = new observation
  55. %preduction
  56. s.x = s.F * s.x
  57. s.P = s.F * s.P * s.F';
  58. %update
  59. K = s.P * inv(s.P + s.R)
  60. s.x = s.x + K *(s.z - s.x);
  61. s.P = s.P - K * s.P;
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement