matrice immagine pixel

The images are numbers, here is the pixel mathematics and the digitization of images

What do i have to do with numbers with the digital images? When we take a photograph with a digital device, such as the phone, visual information is converted and stored in the form of numerical information ready to be viewed later. During the acquisition, in fact, the image is divided into many squares, called pixel, to which some Numbers based on color. The same numbers are used, during viewing, to reconstruct the image as a mosaic made of many pixels.

We see, with a detailed example, how these two passages work, and we explain how a well -defined image differs, from a numerical point of view, from an uninsed image.

Save an image: convert pixels into numbers

Any digital object, like the Images, is saved in the form of data. The data, to be stored, are always codified! Let’s see how it works for images.

The first thing that must be understood is that when digitizing an image this is not acquired as a single block, but is divided into many squares, called pixel. The device of acquisition – As for example the camera – analyzes every pixel and recognizes what are the prevalent colors that appear to us.

Pixel example
Pixel example in a color image. Each “square” obtains its color according to the RGB values ​​that are assigned. Believe: Sobakki

In the case of images in black and white one is defined gray scale More or less wide depending on the needs: in the most defined case, the staircase has 256 values ​​in which 0 is black and 255 is white, and in the middle all the different shades are gradually found. Instead, in the case of color imagesmost electronic devices use the RGB modelthat is Red Green Blue (red, green, blue). In this case, three numbers are attributed to each pixel, one for each color, with values ​​that may vary from 0 to 255 (always in the case of maximum definition).

Example black and white pixels
Example of black and white image. Zoommando it is possible to glimpse the pixels with the various colors of gray.

Depending on the Pixel number used, the image is more or less clear. In fact, keep in mind that, even when it is shown on a screen (or printed), the image is still made up of “squares”: if these are small, our eye perceives a fluid image. The more the pixels used, the more the image is clear, but if we zoomed it enough, it will still be able to reveal the squares that make it up, while if the pixel number is low, we will immediately see results like those we see in the images above, without the need to zoom.

Now, to understand the mechanism of assignment of numbers, let’s see the simplified case of black and white images. The same reasoning that we will do can be expanded to the color case, keeping in mind that the reasoning of the numerical assignment will be made not of a single number (gray) but three numbers (red, green, blue).

The more pixels are, the better the quality of the image

What we need is one conversion tablelike the one in the figure below, which associates different numbers with different quantities of black.
In this case, to further simplify things, we have chosen to consider only 4 different color levels:

  • whiteto which we associated the number 0;
  • light grayor little black, associated with 1;
  • dark graya little black, associated with 2;
  • black associated with 3.
Image digitization: Pixel conversion table in numbers

Let’s imagine we want to convert theimage of a C And, by degrees, we see the different results depending on the number of pixels that are used.
Let’s start with an image a 16 pixelsthat is, dividing the image of the C into a 4 × 4 table. At this point, we assign each square a number from 0 to 4 depending on the amount of black color it contains. The 16 numbers obtained are stored in the device, but what happens when we want to see the image on the monitor? The electronic device we use no longer has access to the original image e it can only be based on numbers which stored: using the same first table converts each number in a uniform color pixels reconstructing an image as in the figure below.

pixel

In this case the result is certainly not very satisfying. We can guess that the image reported is a C, but we are far from a truthful representation of the initial figure. The advantage of saving a few pixels is that it occupies very little space in memory!

Let’s now increase the number of Pixel at 100so as to acquire a 10 × 10 table. As previously done, we assign each square a number from 0 to 4 depending on how much black it is contained specifically pixels. You see that in this way the result is a very blurred C, a bit like we had already seen in the image above that reported the Wikipedia logo. Even if the result still seems unwanted, if we are very shrunk the image of this C, it will be perfectly clear. This makes us understand how much the pixel number depends a lot on the specific image and how it should be used. In one case like ours, for example, use 1000 pixels could be not very functional, going to occupy a lot more space. It is not always necessary to use a high number of pixels, also because they occupy a lot of memory!

pixel100