Hi and welcome to this second video about binary coding. We saw previously how to represent information in the form of bits We are now going to focus more precisely on the method to use this technique to store images and sounds. Nowadays, images are extremely used for video games, television, virtual reality. How do we actually display them? We will use what we call pixels. Pixels are composed of small dots of different colors, green, blue and red, that we will turn on to give the eye the illusion that this is a particular color because they are so small that the eye can't distinguish the three components, red, green and blue. So the eye will believe there is only one color. These pixels will be used for display but also for a lot of things including manipulation as the information in the computer will be stored the same way, whether it is for display, manipulation, printing, etc., we will use this technique using dots called pixels to represent images. To code pixels, we will use sequences of bits. Each of the image's pixels, each of the image's dots will be represented by a set of bits. It will depend on the quantity of colors we would like to display. If we have a black or a white image, each pixel will have only one bit that says "Is it white" or "Is is black". If we want an image in grayscale, we will be able to use 8 bits for each pixel, for example. 8 bits which gives us 256 possible values, 2 power 8. 0 will be black, 255 - the maximum - will be white, and the intermediate values will be gray, more or less dark. And we can generate colors by combining red, green and blue as we said. Here we will use 8 bits for each component. 8 bits for red, so if there is 0 for red, there will be no red in the color. If we have 255 for red, the color will be more red. Each component will have a value between 0 and 255 and by combining them, we can chose the color among lots of different colors: 16 million. The next question is "If I have a sequence of bits that corresponds to an image, how do we know if 24 bits corresponds to 24 black and white pixels, because each pixel uses one bit or has one pixel in colors, because each of these pixels uses 24 bits". We will have to add information to specify that my image is stored by pixels and each pixel is coded with a certain number of bits, black and white, gray or color. And we will also need to specify the image size. Is it kind of rectangular? Elongated? Vertical? Is it a square? The image will be a set of pixels defined by a set of bits, but will also be defined by general characteristics: size, dimensions, height, width and also the number of bits used for each pixel. What we have just described are images called bitmap, which is a set of bits that will describe every pixel. In practice, the computer doesn't know the content of this image. On the right side of this presentation here, we can see a disc which is represented by pixels. The computer doesn't know this is a disc. If it wants to know it, it will need an algorithm for pattern recognition. If it doesn't have it, it only knows there is a set of pixels with more or less black colors and that's it. In practice, an image like this disc, we could code it in a more practical way. Here, for example, instead of saying this is a set of white pixels if we are not in the disc, black if we are in the disc and a little bit gray on the edge of the disc, we could directly say the disc is black, of such size and in a particular area in the image. It would be more specific as we would not have problems at the edge with the slightly gray dots because they overlap on the edge of the disc, and it would be more succinct. Instead of describing every pixel, we would only describe the disc, its color, size, position and that's it. This is what we call a vector image. Rather than describing each pixel of an image, we will describe how to build the image with mathematical forms. Mathematical forms can be discs, rectangles, polygons, more complicated mathematical curves. We will give a set of characteristics to describe this mathematical curve and also information regarding the way to color it, how to eventually color the inside with gradations for example, but always in the mathematical form, with numbers. So this is good for technical drawings, as, in general, technical drawings represent very precise forms, squares, rectangles, circles with specific colors. However, it is more complicated for pictures as pictures have generally a lot of different colors with shapes that are not necessarily mathematical forms as we are used to describing them with squares and rectangles. So it may not be adapted. For pictures, it will be bitmap images with pixels like we have seen before. We will now look into sound coding. Sound is sound waves coming in our ears which are, at every moment, a height and a volume representing the noise that we hear. In practice, we have an infinity of values for every successive time. We can't code them all because we would have an infinity of data to store in the computer. What we will do is what we call sampling. Sampling consists in dividing time in small periods and in saying for example "During the millisecond that just passed, volume and height of the played note was this one". We will average, approximate during small periods of time in order to avoid to store too many values. We will need, of course, to do that in an adapted way. The human ear shouldn't tell the difference, so we will have to use a sampling frequency which is high enough so that the human ear can't tell the difference between having averaged on a millisecond and the real signal. And we shouldn't do too much sampling, and have a too high frequency as we would have too much data to store. So we will do sampling with something which corresponds to what the human ear is capable, which is to hear frequencies between 20 hertz and 20 kilohertz. We will have a set of successive values for each of these small periods of sampling. For each of these values, we will have a set of bits that will describe what the height, volume, etc. of the note is. So this sequence of bits will represent the sound. As for the images, we will see a header which will specify what the frequency of the sampling is. To make it clear, I will give you a number of values and each values corresponds to one millisecond of the sound, for example. That was the usual sound coding. As for images where we could create bitmap images by pixels or vector images with mathematical formula, it is also possible to make something different for the sound. With a musical piece, sound will corresponds to a music score played by instruments. What is a music score? It's successive notes caracterised by height and length of time. The instruments that will play them have also characteristics that we can describe such as the type, the timbre, etc. We can recreate the piece of music by using the information on the score and on the instruments that play it. This will be like for a vector image, we describe the image by the way we create it, using mathematical forms, so here we will describe music explaining how we created it from the music score and the instrument. This enables to code sound in a different way, it is not necessarily adapted for each case, but it can be an interesting approach for pieces of mucic, complementary to the approach we saw earlier. What should we remember from this chapter? First of all, we can code images and sounds with sequences of number of bits, like we did earlier for numbers or letters of a text. Then, we will also have computer programs that will interpret this coding, meaning reading the image information, what is the height, size, number of bits used for the pixels, which will enable the computer to display this image on the screen, to print it, to manipulate it, etc. Similarly, the computer will have a program to read sound information, to play them on a speaker. On the contrary, to bring an image or sound to the computer, a program will receive the signal and translate it in coding with the exact opposite strategy. Between the two, the data is coded with the bits we saw earlier. And whether it is to store on the hard drive, in memory, a transfer on the internet between two computers, audio or photo manipulation, the data will remain coded. It's only when the data will enter the computer to record or to be read or displayed by the computer that we will decode them to give them to human beings.