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, and virtual reality. so how do we actually display them? We will use what we call pixels. Pixels are composed of small dots of different colours, green, blue and red, that we will turn on to give the eye the illusion that this is a particular colour 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 colour. 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 and each of the image's dots will be represented by a set of bits. It will depend on the quantity of colours 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 it 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 grey, more or less dark. And we can generate colours 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 colour.If we have 255 for red, the colour will be more red. Each component will have a value between 0 and 255 and by combining them, we can choose the colour among lots of different colours: 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 colours 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, grey or colour. 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 colours and that's it. In practice, with 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 grey 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 grey dots because they overlap on the edge of the disc, and it would be Instead of describing every pixel, we would only describe the disc, its colour, 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, and circles with specific colours. However, it is more complicated for pictures as pictures have generally a lot of different colours 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. Sounds are waves coming into our ears 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 into small periods and saying for example "During the millisecond that just passed, volume and height of the played note was this one". We will average, and approximate during small periods of time in order to avoid storing too many values. of course, We will need, 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 of hearing which is 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 the height, and volume of the note. So this sequence of bits will represent the sound. As for the images, we will see a header which will specify the frequency of the sampling. To make it clear, I will give you a number of values and each value corresponds to one millisecond of the sound, That was the usual sound coding. As for images where we could create bitmap images by pixels or vector images with a mathematical formula, it is also possible to make something different for the sound. With a musical piece, the sound will correspond to a music score played by instruments. What is a music score? Its successive notes are characterized 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 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 us 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 music, 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 a number of bits, as 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 are the height, size, and the 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.