Presentation is loading. Please wait.

Presentation is loading. Please wait.

การใช้งานโปรแกรม MATLAB ดร. อำนาจ ขาวเน. BASIC ELEMENTS OF MATLAB MATLAB Desktop MATLAB Editor Help System MATLAB (MATrix LABoratory)

Similar presentations


Presentation on theme: "การใช้งานโปรแกรม MATLAB ดร. อำนาจ ขาวเน. BASIC ELEMENTS OF MATLAB MATLAB Desktop MATLAB Editor Help System MATLAB (MATrix LABoratory)"— Presentation transcript:

1 การใช้งานโปรแกรม MATLAB ดร. อำนาจ ขาวเน

2 BASIC ELEMENTS OF MATLAB MATLAB Desktop MATLAB Editor Help System MATLAB (MATrix LABoratory)

3 1 32 4 5 6

4 who, whos – current variables in the workspace save – save workspace variables to *.mat file load – load variables from *.mat file clear – clear workspace variables clc clear screen

5 Data Classes

6 Basic Operators

7 MATLAB Array and Matrix Arithmetic Operators

8 Example of matrix operation

9 How to input a row or column vector

10 How to input a matrix a row at a time

11 How to change entries in a given matrix A

12 Creating M-files Input M-function name must start with the word function Output

13 Graphics x = -pi:.1:pi; y = sin(x); plot(x,y) set(gca,'XTick',-pi:pi/2:pi) set(gca,'XTickLabel',{'-pi','-pi/2','0','pi/2','pi'}) title('Sine Function'); xlabel('Radians'); ylabel('Function Value');

14 subplot Create axes in tiled positions

15 Images in Matlab Reading, writing and querying images

16 Basic display of images

17 imagesc function The imagesc function scales image data to the full range of the current colormap and displays the image.

18 Images in MATLAB Binary images : {0,1} Intensity images : [0,1] or uint8, double etc. RGB images : m-by-n-by-3 Indexed images : m-by-3 color map Multidimensional images m-by-n-by-p (p is the number of layers)

19 Image import and export Read and write images in Matlab >> I=imread('cells.jpg'); >> imshow(I) >> size(I) ans = 479 600 3 (RGB image) >> Igrey=rgb2gray(I); >> imshow(Igrey) >> imwrite(lgrey, 'cell_gray.tif', 'tiff') Alternatives to imshow >>imagesc(I) >>imtool(I) >>image(I)

20 Images and Matrices How to build a matrix (or image)? >> A = [ 1 2 3; 4 5 6; 7 8 9 ]; A = 1 2 3 4 5 6 7 8 9 >> B = zeros(3,3) B = 0 0 0 0 0 0 >> C = ones(3,3) C =1 1 1 1 1 1 >>imshow(A) (imshow(A,[]) to get automatic pixel range)

21 Images and Matrices Accesing image elements (row, column) >> A(2,1) ans = 4 : can be used to extract a whole column or row >> A(:,2) ans = 2 5 8 or a part of a column or row >> A(1:2,2) ans = 2 5 X Y A = 1 2 3 4 5 6 7 8 9

22 Image Arithmetic Arithmetic operations such as addition, subtraction, multiplication and division can be applied to images in MATLAB – +, -, *, / performs matrix operations >> A+A ans = 2 4 6 8 10 12 14 16 18 >> A*A ans = 30 36 42 66 81 96 102 126 150 To perform an elementwise operation use. (.*,./,.*,.^ etc) >> A.*A ans = 1 4 9 16 25 36 49 64 81 A = 1 2 3 4 5 6 7 8 9

23 Converting image types

24 References “Fundamentals of Digital Image Processing A Practical Approach with Examples in Matlab”, by Chris Solomon and Toby Breckon “MATLAB for Image Processing” by Tuo Wang,Feb 12th, 2010 “MATLAB Tutorial” MIT OpenCourseWare http://ocw.mit.edu,Linear Algebra http://ocw.mit.edu


Download ppt "การใช้งานโปรแกรม MATLAB ดร. อำนาจ ขาวเน. BASIC ELEMENTS OF MATLAB MATLAB Desktop MATLAB Editor Help System MATLAB (MATrix LABoratory)"

Similar presentations


Ads by Google