Download presentation
Presentation is loading. Please wait.
1
Lab 9 Intro to Robots
2
Exercise 1: Write the program described in class that makes a red line scan across a photo. Program design: picture = loadPicture(“mypicture.jpg”) copyPic = copyPicture(picture) for each xCoordinate of copyPic: draw a vertical red line show(copyPic) wait(0.2) reconstruct the original pixels in copyPic from picture copy vertical line in original picture to copy def reconstructVerticalLine(pic1,pic2,x): for each yCoordinate of pic2: get pixel (pix1) from pic1 pixel (x,y) get pixel (pix2) from pic2 pixel (x,y) get three colors from pix1 assign three colors to pix2 Intro to Robots
3
I don’t like the name, call your new function filterRedAreas().
Exercise 2: Rewrite findRedAreas() in the class notes to convert all really red areas to totally red (255,0,0) and the rest to black (0,0,0). As a measure of “really red”, let’s say that pixels in the range (>200, <175, <175) are “really red”. I don’t like the name, call your new function filterRedAreas(). Intro to Robots
4
Exercise 3: Modify the program studied in class that finds the red center of a photograph to put a cross-hairs in the same picture. Intro to Robots
5
Write a program that rotates a picture 90°.
Exercise 4: Write a program that rotates a picture 90°. Intro to Robots
6
Modify that program to put a cross-hairs at the center of the blob.
Exercise 5: The second program we studied in class puts a vertical line through the center of the largest red blob in a picture. Modify that program to put a cross-hairs at the center of the blob. Idea for how to do this: Make a copy of the picture by rotating it 90 degrees. In the rotated picture find the x-coordinate of the vertical line through the largest red blob. Use this as the y-coordinate of a horizontal line in the original picture. Intro to Robots
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.