+ All Categories
Home > Documents > Image Processing & Perception

Image Processing & Perception

Date post: 06-Feb-2016
Category:
Upload: bart
View: 33 times
Download: 0 times
Share this document with a friend
Description:
Image Processing & Perception. Sec 9-11 Web Design. Objectives. The student will: Understand an image from the scribbler camera Look at individual pixels in a picture Understand the myro commands to analyze a picture. Pixels. - PowerPoint PPT Presentation
14
Image Processing & Perception Sec 9-11 Web Design
Transcript
Page 1: Image Processing & Perception

Image Processing &Perception

Sec 9-11Web Design

Page 2: Image Processing & Perception

Objectives

The student will:• Understand an image from the scribbler

camera• Look at individual pixels in a picture• Understand the myro commands to analyze a

picture

Page 3: Image Processing & Perception

Pixels

• Each image is made up of several tiny picture elements or pixels.

• In a color image, each pixel contains color information which is made up of the amount of red, green, and blue (RGB). – Each of these values is in the range 0..255– A pixel that is colored pure red will have the RGB

values (255, 0, 0).

Page 4: Image Processing & Perception

Pixels• A low-end camera today has 5 megapixels.

That’s 5,000,000 pixels!• The images obtained from the Scribbler are

256x192 (WxH) pixels or a total of 49,152 pixels.

Page 5: Image Processing & Perception

Taking a Picture

• Remember the command:pic = takePicture("color")

• The picture is now stored in the variable pic, but what is stored?– Think of pic as a table with 192 rows and

256 columns.– Each “cell” in the table tells the color of that

pixel.

Page 6: Image Processing & Perception

Scribbler Pictures

• Look at this picture:– It’s easy to see the

blue chair, the red column and the door but all the computer sees is 49,152 little squares of color.

Page 7: Image Processing & Perception

0 1 2 3 4 5 6 7 8 9 10 11 12 13 … 248 249 250 251 252

0

1

2

3

4

5

...

189

190

191

192

Scribbler Picture• Pixels are numbered starting with the upper left corner

Page 8: Image Processing & Perception

Looking at a picture on the Screen• When you issue the show(pic) command you

can click on the picture, see the pixel selected and R, G, B values for that pixel

Pixel

Red

Green

Blue

Page 9: Image Processing & Perception

Looking at a picture on the Screen

• Pure white is (255, 255, 255)• Pure black is (0, 0, 0)

Page 10: Image Processing & Perception

Myro Image Processing Functions • Myro commands you can use to analyze a image:getWidth(pic) – Returns the width of the picture

width = getWidth(pic)getHeight(pic) – Returns the height of the picture

height = getHeight(pic)getPixel(pic, x, y) – Returns the pixel at specified x- and y-

locationspixel = getPixel(pic, x, y)

getRGB(pixel) – Returns the red, green and blue values of the pixel (between 0 and 255).

r, g, b = getRGB(pixel)

Page 11: Image Processing & Perception

How to look at every pixel in picture

• To scan every pixel in a picture you need a pair of nested for loops:

for x in range(256):for y in range(192):

pixel = getPixel(pic, x, y)r, g, b = getRGB(pixel)

• r now contains the red value, g the green value and b the blue value for that pixel.

Page 12: Image Processing & Perception

Summary• Digital pictures are actually just a combination of

tiny dots called pixels• Each pixel has a single color associated with it.– Colors are combinations of red, green and blue. – Each color has a value of 0 (no color) to 255 (max)

• Scribbler pictures are 256 pixels wide and 192 pixels high for a total of 49,152 pixels.

• getPixel(pic, x, y) and getRGB(pixel) can be used to analyze the colors in a picture

Page 13: Image Processing & Perception

Rest of TodayWrite a program to:1. Take a picture that contains the colors in the front of

the room. Look at the red cone.2. Display the picture on the screen3. Write a program to analyze the picture. If the red

value is greater than 250 then print out the pixel and red, green, and blue values.

print "Pixel is (", x, ", ", y, ") RGB is ", r, g, b

• Assumes the variables x, y, r, g, and b are set.

4. As a team answer this question:– Is checking the R value sufficient for finding red?• If not what other criteria needs to be considered?

Page 14: Image Processing & Perception

Rest of Today

5. Repeat for the other colors. What criteria can be used to distinguish the blue, green, purple and orange papers.


Recommended