Each 0 or 1 in computer code is a bit; bits define the color of a pixel. A pixel defined by 1 bit can only be one of two colors: black or white.
Two bits define each pixel in Photo 2. Here, a pair of numbers defines the color—or, in this case, shade of gray—of each pixel. In Photo 2, there are four possible shades of gray because there are four possible combinations of 0s and 1s. Notice how the code to the right of the image relates to the colors of each pixel.
With more bits defining each pixel, the image can have more information, show more detail, and have more shades of gray.