Image resolution
A resolution can be defined as the total number of pixels in an image. This has been
discussed in Image resolution. And we have also discussed, that clarity of an image does
not depends on number of pixels, but on the spatial resolution of the image. This has
been discussed in the spatial resolution. Here we are going to discuss another type of
resolution which is called gray level resolution.
Gray level resolution
Gray level resolution refers to the predictable or deterministic change in the shades or
levels of gray in an image.
In short gray level resolution is equal to the number of bits per pixel.
We have already discussed bits per pixel in our tutorial of bits per pixel and image
storage requirements. We will define bpp here briefly.
BPP
The number of different colors in an image is depends on the depth of color or bits per
pixel.
Mathematically
The mathematical relation that can be established between gray level resolution and bits
per pixel can be given as.
In this equation L refers to number of gray levels. It can also be defined as the shades
of gray. And k refers to bpp or bits per pixel. So the 2 raise to the power of bits per pixel
is equal to the gray level resolution.
For example:
The above image of Einstein is an gray scale image. Means it is an image with 8 bits per
pixel or 8bpp.
Now if were to calculate the gray level resolution, here how we gonna do it.
It means it gray level resolution is 256. Or in other way we can say that this image has
256 different shades of gray.
The more is the bits per pixel of an image, the more is its gray level resolution.
Defining gray level resolution in terms of bpp
It is not necessary that a gray level resolution should only be defined in terms of levels.
We can also define it in terms of bits per pixel.
For example
If you are given an image of 4 bpp, and you are asked to calculate its gray level
resolution. There are two answers to that question.
The first answer is 16 levels.
The second answer is 4 bits.
Finding bpp from Gray level resolution
You can also find the bits per pixels from the given gray level resolution. For this, we just
have to twist the formula a little.
Equation 1.
This formula finds the levels. Now if we were to find the bits per pixel or in this case k,
we will simply change it like this.
K = log base 2(L) Equation (2)
Because in the first equation the relationship between Levels (L ) and bits per pixel (k)
is exponentional. Now we have to revert it, and thus the inverse of exponentional is log.
Lets take an example to find bits per pixel from gray level resolution.
For example:
If you are given an image of 256 levels. What is the bits per pixel required for it.
Putting 256 in the equation, we get.
K = log base 2 ( 256)
K = 8.
So the answer is 8 bits per pixel.
Gray level resolution and quantization:
The quantization will be formally introduced in the next tutorial, but here we are just going
to explain the relation ship between gray level resolution and quantization.
Gray level resolution is found on the y axis of the signal. In the tutorial of Introduction to
signals and system, we have studied that digitizing a an analog signal requires two steps.
Sampling and quantization.
Sampling is done on x axis. And quantization is done in Y axis.
So that means digitizing the gray level resolution of an image is done in quantization.
We have introduced quantization in our tutorial of signals and system. We are formally
going to relate it with digital images in this tutorial. Lets discuss first a little bit about
quantization.
Digitizing a signal
As we have seen in the previous tutorials, that digitizing an analog signal into a digital,
requires two basic steps. Sampling and quantization. Sampling is done on x axis. It is
the conversion of x axis (infinite values) to digital values.
The below figure shows sampling of a signal.
Sampling with relation to digital images
The concept of sampling is directly related to zooming. The more samples you take, the
more pixels, you get. Oversampling can also be called as zooming. This has been
discussed under sampling and zooming tutorial.
But the story of digitizing a signal does not end at sampling too, there is another step
involved which is known as Quantization.
What is quantization
Quantization is opposite to sampling. It is done on y axis. When you are quantizing an
image, you are actually dividing a signal into quanta(partitions).
On the x axis of the signal, are the co-ordinate values, and on the y axis, we have
amplitudes. So digitizing the amplitudes is known as Quantization.
Here how it is done
You can see in this image, that the signal has been quantified into three different levels.
That means that when we sample an image, we actually gather a lot of values, and in
quantization, we set levels to these values. This can be more clear in the image below.
In the figure shown in sampling, although the samples has been taken, but they were
still spanning vertically to a continuous range of gray level values. In the figure shown
above, these vertically ranging values have been quantized into 5 different levels or
partitions. Ranging from 0 black to 4 white. This level could vary according to the type of
image you want.
The relation of quantization with gray levels has been further discussed below.
Relation of Quantization with gray level resolution:
The quantized figure shown above has 5 different levels of gray. It means that the image
formed from this signal, would only have 5 different colors. It would be a black and white
image more or less with some colors of gray. Now if you were to make the quality of the
image more better, there is one thing you can do here. Which is, to increase the levels,
or gray level resolution up. If you increase this level to 256, it means you have an gray
scale image. Which is far better then simple black and white image.
Now 256, or 5 or what ever level you choose is called gray level. Remember the formula
that we discussed in the previous tutorial of gray level resolution which is,
We have discussed that gray level can be defined in two ways. Which were these two.
• Gray level = number of bits per pixel (BPP).(k in the equation)
• Gray level = number of levels per pixel.
In this case we have gray level is equal to 256. If we have to calculate the number of
bits, we would simply put the values in the equation. In case of 256levels, we have 256
different shades of gray and 8 bits per pixel, hence the image would be a gray scale
image.
Reducing the gray level
Now we will reduce the gray levels of the image to see the effect on the image.
For example
Lets say you have an image of 8bpp, that has 256 different levels. It is a grayscale image
and the image looks something like this.
256 Gray Levels
Now we will start reducing the gray levels. We will first reduce the gray levels from 256
to 128.
128 Gray Levels
There is not much effect on an image after decrease the gray levels to its half. Lets
decrease some more.
64 Gray Levels
Still not much effect, then lets reduce the levels more.
32 Gray Levels
Surprised to see, that there is still some little effect. May be its due to reason, that it is
the picture of Einstein, but lets reduce the levels more.
16 Gray Levels
Boom here, we go, the image finally reveals, that it is effected by the levels.
8 Gray Levels
4 Gray Levels
Now before reducing it, further two 2 levels, you can easily see that the image has been
distorted badly by reducing the gray levels. Now we will reduce it to 2 levels, which is
nothing but a simple black and white level. It means the image would be simple black
and white image.
2 Gray Levels
Thats the last level we can achieve, because if reduce it further, it would be simply a
black image, which can not be interpreted.
Contouring
There is an interesting observation here, that as we reduce the number of gray levels,
there is a special type of effect start appearing in the image, which can be seen clear in
16 gray level picture. This effect is known as Contouring.
Iso preference curves
The answer to this effect, that why it appears, lies in Iso preference curves. They are
discussed in our next tutorial of Contouring and Iso preference curves.
What is contouring?
As we decrease the number of gray levels in an image, some false colors, or edges start
appearing on an image. This has been shown in our last tutorial of Quantization.
Lets have a look at it.
Consider we, have an image of 8bpp (a grayscale image) with 256 different shades of
gray or gray levels.
This above picture has 256 different shades of gray. Now when we reduce it to 128 and
further reduce it 64, the image is more or less the same. But when re reduce it further to
32 different levels, we got a picture like this
If you will look closely, you will find that the effects start appearing on the image.These
effects are more visible when we reduce it further to 16 levels and we got an image like
this.
These lines, that start appearing on this image are known as contouring that are very
much visible in the above image.
Increase and decrease in contouring
The effect of contouring increase as we reduce the number of gray levels and the effect
decrease as we increase the number of gray levels. They are both vice versa
VS
That means more quantization, will effect in more contouring and vice versa. But is this
always the case. The answer is No. That depends on something else that is discussed
below.
Dithering
Dithering is the process by which we create illusions of the color that are not present
actually. It is done by the random arrangement of pixels.
For example. Consider this image.
This is an image with only black and white pixels in it. Its pixels are arranged in an order
to form another image that is shown below. Note at the arrangement of pixels has been
changed, but not the quantity of pixels.
Why Dithering?
Why do we need dithering, the answer of this lies in its relation with quantization.
Dithering with quantization
When we perform quantization, to the last level, we see that the image that comes in the
last level (level 2) looks like this.
Now as we can see from the image here, that the picture is not very clear, especially if
you will look at the left arm and back of the image of the Einstein. Also this picture does
not have much information or detail of the Einstein.
Now if we were to change this image into some image that gives more detail then this,
we have to perform dithering.
Performing dithering
First of all, we will work on threholding. Dithering is usually working to improve
thresholding. During threholding, the sharp edges appear where gradients are smooth
in an image.
In thresholding, we simply choose a constant value. All the pixels above that value are
considered as 1 and all the value below it are considered as 0.
We got this image after thresholding.
Since there is not much change in the image, as the values are already 0 and 1 or black
and white in this image.
Now we perform some random dithering to it. Its some random arrangement of pixels.
We got an image that gives slighter of the more details, but its contrast is very low.
So we do some more dithering that will increase the contrast. The image that we got is
this:
Now we mix the concepts of random dithering, along with threshold and we got an image
like this.
Now you see, we got all these images by just re-arranging the pixels of an image. This
re-arranging could be random or could be according to some measure.