Presentation is loading. Please wait.

Presentation is loading. Please wait.

MA/CS375 Fall 2002 1 MA/CS 375 Fall 2002 Lecture 5.

Similar presentations


Presentation on theme: "MA/CS375 Fall 2002 1 MA/CS 375 Fall 2002 Lecture 5."— Presentation transcript:

1 MA/CS375 Fall 2002 1 MA/CS 375 Fall 2002 Lecture 5

2 MA/CS375 Fall 2002 2 Individual Exercise 1)Create two curves on the same graph: F = 1/(1+x^2) G = exp(x^3) 2)Plot the points at 33 points equally spaced between 0 and 1 3)Use black *’s for F and green o’s for G 4)Label the horizontal and vertical axes 5)Create a title (including your name) 6)Create a legend 7)Make sure the font’s are legible for my old eyes (also figure out how to change the axis fonts) 8)Print out your graph and hand it in. Recall

3 MA/CS375 Fall 2002 3 Plotting Two-Dimensional Data

4 MA/CS375 Fall 2002 4 Example 7 (Plotting Two-dimensional Data) 1)create two vectors x1d and y1d, with 20 entries from 0.0 to 1.0 2)create matrices of values using the x1d and y1d to distribute points in the unit square with 20 points in the x and y directions. 3)plot results in a graph.

5 MA/CS375 Fall 2002 5 Results From Example 7

6 MA/CS375 Fall 2002 6 Where are we going with this? We can evaluate a function at the two dimensional points (x2d,y2d) We can plot contours of this function where: a contour is a curve in the domain of the function where the value of the function is constant.

7 MA/CS375 Fall 2002 7 Example 8 (plotting contours of a two-dimensional function)

8 MA/CS375 Fall 2002 8 Example 9 (plotting two-dimensional function as a surface)

9 MA/CS375 Fall 2002 9 Example 9 cont. (plotting two-dimensional function as a smooth surface)

10 MA/CS375 Fall 2002 10 subplot If you wish to create a figure with two sub-figures you can use the subplot function: subplot(1,2,1) requests 1 row of figures 2 columns of figures 1 st figure

11 MA/CS375 Fall 2002 11 subplot(1,2,1)subplot(1,2,2)

12 MA/CS375 Fall 2002 12 Manipulating Images in Matlab Raster scan based images (even those using compression) can be read into Matlab as arrays. These include amongst others: –tiff, gif, bmp, png, hdf, pcx

13 MA/CS375 Fall 2002 13 imread Loading an image is easy. First find an “appropriate” jpeg or tiff image – use the internet.. Save it in your working directory Start Matlab and change to your working directory

14 MA/CS375 Fall 2002 14 imread cont

15 MA/CS375 Fall 2002 15 For jpeg and tiff images the array read in is three dimensional. The first dimension gives the row of pixels. The second index gives the image column of pixels, and the third index gives the pixel color type.

16 MA/CS375 Fall 2002 16 Finding The Color Composition Up of a Pixel So let’s find the color composition of the pixel in the 11 th row and 14 th column

17 MA/CS375 Fall 2002 17 We wish to look at the color intensities of the pixel in the 11 th row and 14 th column. Notice we use : to list all the color intensities Red intensity is 92/255 Green intensity is 143/255 Blue intensity is 126/255

18 MA/CS375 Fall 2002 18 image We can plot the image as a figure image(pic)

19 MA/CS375 Fall 2002 19 eeeck

20 MA/CS375 Fall 2002 20

21 MA/CS375 Fall 2002 21 My Warhol Phase

22 MA/CS375 Fall 2002 22 uint8 and all that The image is stored as a three-dimensional array of unsigned bytes We actually want to manipulate these arrays – but Matlab will not allow us to perform algebraic operations on uint8’s First we need to cast the image array to doubles

23 MA/CS375 Fall 2002 23 So the intensity ofeach pixel gets squared and normalized to be less than 256. Converted back to uint8 and plot..

24 MA/CS375 Fall 2002 24 Left: the original me Right: me squared (and not any better)

25 MA/CS375 Fall 2002 25 Exercise: Blending Two Images Find one partner to work with (i.e. your neighbor) Write a script which reads in two images. Use the min function to find the minimum number of rows for both pictures (MINrows) Use the min function to find the minimum number of columns for both pictures (MINcolumns) Crop the images using > pic1 = pic1(1:MINrows,1:MINcols,1:3) > pic2 = pic2(1:MINrows,1:MINcols,1:3) Create a third picture (pic3) which is the average of pic1 and pic2 Plot pic1,pic2,pic3 in the same figure using subplot Put your names on the title, print it out and hand it in.

26 MA/CS375 Fall 2002 26 Summary of Lecture 5 We have learnt how to: – plot a two-dimensional graph – plot contours of a two-dimensional function – plot a two-dimensional function as a surface – read, plot and manipulate images


Download ppt "MA/CS375 Fall 2002 1 MA/CS 375 Fall 2002 Lecture 5."

Similar presentations


Ads by Google