Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [outputPicture] = smoothMe (inputPicture)
- G=fspecial('gaussian', [10 10],3); %Create Gaussian mask
- outputPicture = conv2(inputPicture,G,'same'); %Convolve the grayscale image with Gaussian filters
- end
- Ex1 :
- function [H_outputPicture, V_outputPicture] = sobelOperators(inputPicture)
- %Convolve the grayscale image with horizontal Sobel filters
- H_outputPicture = conv2(inputPicture, [1 2 1; 0 0 0; -1 -2 -1])
- %Convolve the grayscale image with vertical Sobel filters
- V_outputPicture = conv2(inputPicture, [1 0 -1; 2 0 -2; 1 0 -1])
- end
- Ex2 :
- function[ match ] = recogniseFace( Unknown_face, Train_face )
- %Training
- [U,S,D]=svds(Train_Face, 30) %First 30 Eigen vectors
- 1TFaces= U'*Train_Face %low dimension Training Face with 20 dimension
- %Prediction
- 1UnknownFace = U'*Unknown_Face
- EuclideanDist=sqrt(sum((1TFaces-repmat(1UnknownFace,[1 34])).^2))
- [match_score, match]=min(EuclideanDist);
- end
- Ex3 :
- function [ ranks, frequency ] = querystring( query, Tf, uniqueCell )
- queryCell = strsplit(query)';
- number_of_documents=size(Tf,2);
- for i = 1 : size(queryCell,1)
- frequency(i,1:number_of_documents)= Tf(find(strcmp(uniqueCell,queryCell(i))),:);
- end
- frequency=sum(frequency);
- [frequency, ranks]=sort(frequency,'descend');
- end
- Ex4
- function [tfidfM] = tfidf(Tf)
- %Input Tf is the term frequency matrix (importance of a document to a term)
- %N is the total number of documents in the corpus
- N = size(Tf, 2); %number of columns
- n = sum (Tf > 0, 2); %n(t) is the number of the documents in the corpus that contains term t
- idf = log(N./(1+n)); %Inverse Document Frequency
- %Term frequency inverse document frequency Matrix
- tfidfM = Tf.*repmat(idf,[1 size(Tf, 2)]);
- end
- Ex5
- function [ s ] = kalmanfilter( s )
- %Kalman filter store state in variable s
- %s is a structure with field
- %s.x = state variables
- %s.F = transformation matrix
- %s.P = covariance of variables (how to initialize? with R)
- %s.R = covariance of sensor (Radar) / sampling error
- %s.z = new observation
- %preduction
- s.x = s.F * s.x
- s.P = s.F * s.P * s.F';
- %update
- K = s.P * inv(s.P + s.R)
- s.x = s.x + K *(s.z - s.x);
- s.P = s.P - K * s.P;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement