Lecture - Matlab tutorial

Lecture - Matlab tutorial - L M M O M L L Bahadir K....

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
EE 4780 Matlab tutorial
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Bahadir K. Gunturk 2 MATLAB Review your matrix-vector knowledge Matlab help files are helpful to learn it Exercise: f = [1 2; 3 4] g = [1; 1] g = [1 1] g’ z = f * g’ n=0:10 plot(sin(n)); plot(n,sin(n)); title(‘Sinusoid’); xlabel(‘n’); ylabel(‘Sin(n)’); n=0:0.1:10 plot(n,sin(n)); grid; figure; subplot(2,1,1); plot(n,sin(n)); subplot(2,1,2); plot(n,cos(n));
Background image of page 2
Bahadir K. Gunturk 3 MATLAB Some more built-ins a = zeros(3,2) b = ones(2,4) c = rand(3,3) %Uniform distribution help rand help randn %Normal distribution d1 = inv(c) d2 = inv(rand(3,3)) d3 = d1+d2 d4 = d1-d2 d5 = d1*d2 d6 = d1.*d3 e = d6(:)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Bahadir K. Gunturk 4 MATLAB Image processing in Matlab x=imread(‘cameraman.tif’); figure; imshow(x); [h,w]=size(x); y=x(0:h/2,0:w/2); imwrite(y,’man.tif’); % To look for a keyword lookfor resize 1 2 [0,0] [0,1] [0, 1] [1,0] [1,1] [1, 1] [ , ] [ 1,0] [ 1, 1] MxN x x x N x x x N x n n x M x M N - - = - - - L
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: L M M O M L L Bahadir K. Gunturk 5 MATLAB M-file Save the following as myresize1.m function [y]=myresize1(x) % This function downsamples an image by two [h,w]=size(x); for i=1:h/2, for j=1:w/2, y(i,j) = x(2*i,2*j); end end Compare with myresize2.m function [y]=myresize2(x) % This function downsamples an image by two [h,w]=size(x); for i=0:h/2-1, for j=0:w/2-1, y(i+1,j+1) = x(2*i+1,2*j+1); end end Compare with myresize3.m function [y]=myresize3(x) % This function downsamples an image by two y = x(1:2:end,1:2:end); We can add inputs/outputs function [y,height,width]=myresize4(x,factor) % Inputs: % x is the input image % factor is the downsampling factor % Outputs: % y is the output image % height and width are the size of the output image y = x(1:factor:end,1:factor:end); [height,width] = size(y);...
View Full Document

This note was uploaded on 11/28/2011 for the course EE 4780 taught by Professor Staff during the Spring '08 term at LSU.

Page1 / 5

Lecture - Matlab tutorial - L M M O M L L Bahadir K....

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online