Chapter 9 182Your robot has a small digital camera that can be used to take pictures. A picture taken by a digital camera is represented as an image. As you have seen in the previous chapter images can be drawn and moved about in a graphics window just as if it were any other graphics object (like a line, circle, etc.). We also saw in Chapter 5 how an image taken from the Scribbler’s camera can be viewed on your monitor in a separate window. In this chapter we will learn how to do computing on images. We will learn how images are represented and how we can create them via computation and also process them in many different ways. The representation of images we will use is same as those used by most digital cameras and cell phones and the same representation can be used to display them in a web page. We will also learn how an image taken by the robot’s camera can be used to serve as the camera’s eye into its world using some image understanding techniques. Image understanding is the first step in visual perception. A robot equipped with even the most rudimentary visual perception capabilities can be designed to carry out more interesting behaviors. What is an Image? In Myro you can issue a command for the robot to take a picture and display it on the computer’s monitor using the commands: pic = takePicture() show(pic) The picture on the next page shows an example image taken from the Scribbler’s camera. An 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 (also called, RGB) values. Each of these values can be in the range [0..255] and hence it takes 3 bytes or 24 bits to store the information contained in a single pixel. A pixel that is colored pure red will have the RGB values (255, 0, 0). A grayscale image, on the other hand, only contains the level of gray in a pixel which can be represented in a single byte (8 bits) as a number ranging from 0..255 where 0 is black and 255 is white. The entire image is just a 2-dimensional array of pixels. For example, the images obtained from the Scribbler have 256x192 (WxH) or a total of 49,152 pixels. Since each pixel requires 3 bytes of data, this image has a size of 147,456 bytes. All digital cameras are sold by specifying the number of megapixels. For example, the camera shown below is rated at 6.3 megapixels. This refers to the

This
preview
has intentionally blurred sections.
Sign up to view the full version.

Image Processing & Perception 183size of the largest image that it can take. The more pixels in an image the better the image resolution can be when it is printed. With a 6.3 megapixel image you will be able to create good quality prints as large as 13x12 inches (or even larger). By comparison, a conventional 35mm photographic film has roughly 4000x3000 or 12 million pixels. Professional digital cameras easily surpass this

This is the end of the preview.
Sign up
to
access the rest of the document.