Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.

Similar presentations


Presentation on theme: "Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike."— Presentation transcript:

1 Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Based on a work at www.peerinstruction4cs.org.Dr. Cynthia Lee, UCSDCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported Licensewww.peerinstruction4cs.org 1

2 Making a Sunset 2 >> im(:,:,2) = im(:,:,2) *.6; >> im(:,:,3) = im(:,:,3) *.6;

3 Making a Sunset >> im(:,:,2) = im(:,:,2) *.6; >> im(:,:,3) = im(:,:,3) *.6; 3

4 What does this code do? » im = imread(‘sunny-beach.jpg’); » for i = 1:size(im,1) im(i,:,2) = im(i,:,2) *.6; im(i,:,3) = im(i,:,3) *.6; imshow(im); drawnow; end » a)Changes an image to sunset one row at a time b)Changes an image to sunset one column at a time c)Changes an image to sunset one pixel at a time d)Other 4

5 What does this code do? » im = imread(‘sunny-beach.jpg’); » for i = 1:size(im,2) im(:,i,2) = im(:,i,2) *.6; im(:,i,3) = im(:,i,3) *.6; imshow(im); drawnow; end » a)Changes an image to sunset one row at a time b)Changes an image to sunset one column at a time c)Changes an image to sunset one pixel at a time d)Other 5

6 What does this code do? » im = imread(‘sunny-beach.jpg’); » for row = 1:size(im,1) for col = 1:size(im,2) im(row,col,2) = im(row,col,2) *.6; im(row,col,3) = im(row,col,3) *.6; imshow(im); drawnow; end » a)Changes an image to sunset one row at a time b)Changes an image to sunset one column at a time c)Changes an image to sunset one pixel at a time d)Other 6

7 Which pattern shows the order in which the pixels change? » im = imread(‘sunny-beach.jpg’); » for row = 1:size(im,1) for col = 1:size(im,2) im(row,col,2) = im(row,col,2) *.6; im(row,col,3) = im(row,col,3) *.6; imshow(im); drawnow; end » 7 A B CE Other D

8 » for row = 1:size(im,1) for col = 1:size(im,2) im(col,row,2) = im(col,row,2) *.6; im(col,row,3) = im(col,row,3) *.6; imshow(im); drawnow; end » for row = 1:size(im,1) for col = 1:size(im,2) im(row,col,2) = im(row,col,2) *.6; im(row,col,3) = im(row,col,3) *.6; imshow(im); drawnow; end 8 A C Other, or can’t be done Which code makes the pixels change this other way? Original » for col = 1:size(im,2) for row = 1:size(im,1) im(row,col,2) = im(row,col,2) *.6; im(row,col,3) = im(row,col,3) *.6; imshow(im); drawnow; end B


Download ppt "Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike."

Similar presentations


Ads by Google