Module 1
Module 1
PROCESSING
Introduction –Steps in Digital Image Processing, concept of spatial and
intensity resolution, Relationships between pixels
Point Processing : Image Negative, Log Transform, Power Law transform, Bit
plane slicing, Contrast stretching , Histogram equalization and Histogram
Specification
Human beings are primarily visual creatures who depend on their eyes to
gather information around them. Of the five senses that human beings have, sight
ar
is what we depend upon the most. Not many animals depend on their visual
systems; the way human beings do.
nk
Bats use high frequency sound waves. They emit sound waves which reflect
back when they encounter some obstruction. Cats have poor vision but an excellent
ao
sense of smell. Snakes locate prey by heat emission and fish have organs that sense
electrical fields.
g
What Do We Mean by Image Processing?
or
The eye records the scene and sends signals to the brain. These signals get
processed in the brain and some meaningful information is obtained. Let us take a
li
simple example: when we see fire, we immediately identify it as something hot. Two
things have happened here.
ja
(1) The brain processed this scene and gave out a warning signal.
We start processing images from the day we are bom. Hence image processing
is an integral part of us and we continue to process images till the day we die. So
even if this subject seems to be new, we have been subconsciously doing this, all
these years. The human eye-brain mechanism represents the ultimate imaging
system.
Apart from our vision, we have another important trait that is common to all
human beings. We like to store information, analyse it, discuss it with others and
try to better it. This trait of ours is responsible for the rapid development of the
human race.
Early human beings strove to record their world by carving crude diagrams on
stone. All the drawings that we see in old caves is just that; storing images seen,
trying to analyse them and discussing it with others in the tribe. Refer below
figure:
ar
nk
Figure 11
ao
This art developed through the ages by way of materials and skill. By the mid-
nineteenth century, photography was well established. Image processing that we
g
study starts from this era.
or
Though it was stated earlier that the human eye-brain mechanism represents the
ultimate imaging system, image processing as a subject involves processing
K
Images from a camera are fed into a computer where algorithms are written to
process these images. Here, the camera replaces the human eye and the computer
ja
Figure 12
Image
Let us now define what we mean by an image. The world around us is 3-
dimensional, while images obtained through a camera are 2-dimensional. Hence an
image can be defined as a 2-dimensional representation of a 3-dimensional world.
Consider the image shown in Fig.
Figure 13
In moving from the 3-dimensional world to the 2-dimensional image, we lose one
dimension. Depth information is lost as can be seen from the above figure; the
ar
handle of the tea cup is missing.
All family pictures, photographs on identity cards etc. are 2-dimensional. If this
nk
statement is not clear, let us take a simple example.
ao
Example of a 1 •dimensional and a 2-dlmenslonal signal
Consider a voltage signal shown in Fig. 1.4. We are all familiar with a signal of this
g
kind. Here the voltage is varying with respect to time. This is a typical 1-
or
dimensional signal. If we want to locate a dot on the wave, all we need to know is it
corresponding time.
K
li
ja
an
Figure 14
it
Let us see why images are 2-dimensional functions. Consider the image shown in
G
Fig.1.5.
Figure 15
In this case, to locate the dot shown, we need to know its position in two directions
(x and y) Fig.1.6 Hence all images that we see are 2-dimensional functions.
Figure 16
A typical image is represented as shown in Fig.1-6. Here (x1,y1) are the spatial
ar
coordinates and f is the grey level (colour in the case of colour image) at that point.
Hence grey level f varies with respect to the x and y coordinates.
nk
Image: An image may be defined as a two dimensional function f(x, y) where x & y
are spatial coordinates and amplitude of at any pair of coordinates(x, y) is called the
ao
intensity or grey level of the image at that point.
Digital Image: when x, y & amplitude values of f are all finite, discrete quantities
we call the image a digital image.
g
Digital image is composed of a finite number of elements.
or
These elements are known as pixel (picture element).
Pixels have particular location and value.
K
The apparatus shown in Fig. 1.2 will work only if light is incident on the object.
G
What we call light is actually a very small section of the electromagnetic energy
spectrum. The entire spectrum is shown in Fig. 1.7.
Figure 18
Electromagnetic energy, exists in the simultaneous form of electricity and
magnetism. These two forms of the same energy are transmitted together as
electromagnetic radiation. One cannot exist without the other. A flow of
electric current always produces magnetism, and magnetism is used to
produce electricity. Electromagnetic radiation is propagated outwards from
its source at a velocity of 300,00.0000 meters per second (3x10* m/sec).
Although our natural source of electromagnetic radiation is the sun. there are
also a number of man-made sources which. among many others, include
tungsten filament lamps, gas discharge lamps and lasers. Light is a band of
electromagnetic radiation mediated by the human eye and is limited to a
ar
spectrum extending from 380 nm to 760 nm. Most of the images that we
encounter in our day-to-day life are taken from cameras which are sensitive
to this range of the electromagnetic spectrum (380-760 nm). We must not
nk
forget though, that there are cameras which are capable of detecting infrared,
ultraviolet light. X-rays and radio waves too. The electromagnetic spectrum
can be expressed in terms of wavelength and frequency. The wavelength (λ)
ao
and the frequency (v) are related by the expression
λ= c/v
g
or
Applications of Image Processing
Image Processing as a subject is growing leaps and bounds. From a very
K
modest beginning. Image Processing, has been constantly evolving. With the
advent of computers, the area of image processing has emerged today as a
subject of interdisciplinary study. Given below are a few areas of image
li
processing.
ja
ar
modalities which use image processing extensively are X-rays, Computer
Tomography (CT), Magnetic resonance Imaging (MRI), Positron Emission
Tomography (PET).
nk
Basic components of Image Processing System :
g ao
or
K
li
ja
an
performance.
- Software: for image processing consists of specialized modules that perform
specific tasks.
Mass storage: capability is must in image processing applications. Digital
storage for image processing applications falls into three principle categories:
(1) short-term storage
(2) on-line storage for relatively fast recall,
(3) archival storage, characterized by infrequent access.
ar
nk
g ao
or
K
li
1. Image Acquisition:
ja
- This is the first step or process of the fundamental steps of digital image
processing. Image acquisition could be as simple as being given an image that
an
is already in digital form. Generally, the image acquisition stage involves pre-
processing, such as scaling etc.
2. Image Enhancement:
it
3. Image Restoration:
- Image restoration is an area that also deals with improving the appearance of
an image. However, unlike enhancement, which is subjective, image
restoration is objective, in the sense that restoration techniques tend to be
based on mathematical or probabilistic models of image degradation.
6. Compression:
- Compression deals with techniques for reducing the storage required to save
an image or the bandwidth to transmit it. Particularly in the uses of internet it
is very much necessary to compress data.
ar
7. Morphological Processing:
- Morphological processing deals with tools for extracting image components
that are useful in the representation and description of shape.
nk
8. Segmentation:
- Segmentation procedures partition an image into its constituent parts or
ao
objects. In general, autonomous segmentation is one of the most difficult
tasks in digital image processing. A rugged segmentation procedure brings
the process a long way toward successful solution of imaging problems that
g
require objects to be identified individually.
or
9. Representation and Description:
- Representation and description almost always follow the output of a
K
segmentation stage, which usually is raw pixel data, constituting either the
boundary of a region or all the points in the region itself.
- Choosing a representation is only part of the solution for transforming raw
li
ar
nk
g ao
or
K
- The most common sensor of this type is the photodiode, which is made of
silicon The use of a filter in front of a sensor improves selectivity. For example,
a green (pass)filter in front of a light sensor favours light in the green band of the
it
color spectrum.- As a consequence, the sensor output will be stronger for green
G
ar
- In-line sensors are used routinely in airborne imaging applications, in which the
imaging system is mounted on an aircraft that flies at a constant altitude and
nk
speed over the geographical area to be imaged.
- One-dimensional imaging sensor strips that respond to various bands of the
electromagnetic spectrum are mounted perpendicular to the direction of flight.-
ao
The imaging strip gives one line of an image at a time, and the motion of the
strip completes the other dimension of a two-dimensional image.
- Sensor strips mounted in a ring configuration are used in medical and industrial
g
imaging to obtain cross sectional (“slice”) images of 3 -D objects.
- A rotating X-ray source provides illumination and the portion of the sensors
or
opposite the source collect the X-ray energy that pass through the object.
- This is the basis for medical and industrial computerized axial tomography
K
(CAT)imaging
li
ja
an
it
G
nk
Projection of the scene onto the imageplane. (e) Digitized image.
- This type of arrangement is found in digital cameras. A typical sensor for these
ao
cameras is a CCD array, which can be manufactured with a broad range of
sensing properties and can be packaged in rugged arrays of 4000 * 4000
elements or more.
g
or
The response of each sensor is proportional to the integral of the light energy
projected on to the surface of the sensor, a property that is used in astronomical
and other applications requiring low noise images.
K
- The first function performed by the imaging system in Fig.(c) is to collect the
incoming energy and focus it onto an image plane.
- If the illumination is light, the front end of the imaging system is a lens, which
li
projects the viewed scene onto the lens focal plane as Fig.(d) shows.
- The sensor array, which is coincident with the focal plane, produces outputs
ja
- The o/p of most sensors is a continuous voltage w/f whose amplitude & spatial
behaviour are related to the physical phenomenon being sensed.
G
- To create a digital image, we need to convert the continuous sensed data into
digital form. This involves two processes: Sampling and Quantization.
ar
nk
g ao
Fig (a) shows continuous image f(X,Y) that we want to convert into digital
image - Continuous in x and y coordinates & amplitude also.
or
- We have to sample the function in both coordinates and in amplitude.
-Digitizing the coordinate values is called sampling.
K
bottom part. - Samples are shown as small white squares superimposed on the
function. - Set of discrete samples gives sampling function.
an
shown in fig (d). - After this process we will get image which shown in below
figure.
G
ar
nk
Quantization: The samples values are represented by finite set of integer values.
This is known as quantization
ao
Question: Justify “Quality of picture depends on the number of pixels & grey
levels”. OR g
Justify “Quality of an image is decided by its tonal and spatial
or
resolution”.
K
Answer:
- Every image is seen on screen is actually in matrix form. Each element of matrix is
li
If size of N x M is large than pixel value becomes more & sampling rate will be
increased therefore, we will get better resolution (quality). Value of each pixel is
it
ar
X 8 inches. The sampling resolution is 5 cycles/mm. How many pixels are
required? Will an image of size 256 X 256 be enough?
nk
Solution:
- 1 cycle/mm = 1 line pair /mm
- 1 line pair means 1 line white and 1 line black
ao
- For 1 line pair at least we require 2 pixels/mm
- So 5 cycle/mm = 10 pixels/mm
- Size is 8 inch X 8 inch g
- 1 inch = 25.4 mm
- 8 X 25.4= 203.2 mm
or
- 203.2 mm X 203.2 mm
- each mm there are 10 pixels
K
Image types
ja
image. The range of the colours in 8 bit varies from 0-255, where 0 stands for
black, 255 stands for white and 127 stands for grey colour.
3) Colour image(24 bit): 24 bit colour format is also known as true colour
format. In a 24 bit colour format, the 24 bits are again distributed in three
different formats of Red, Green and Blue.
Since 24 is equally divided on 8, so it has been distributed equally between three
different colour channels.
- Their distribution is like this. 8 bits for R, 8 bits for G, 8 bits for B. A 24-bit
ar
colour image supports 16777216 diff combination of colours. Colour image can
be converted in grey scale image using this equation
nk
- X= 0.30 R + 0.59G + 0.11B.
4) Volume Image: A 3-dimensional image is an example. It can be obtained
from some medical imaging equipment in which individual data points are
ao
called “Voxels”, which stands for volume pixels. A CT scan is an example of
volume image.
g
Image file format:
or
1) BMP (bit mapped graphic Image): colour as well as monochrome image. - Ex.
Paint and saved images in computer.
- Quality is good but more storage is required.
K
2) TIFF (also known as TIF) :TIFF stands for Tagged Image File Format.
- TIFF images create very large file sizes.
- TIFF images are uncompressed and thus contain a lot of detailed image data
li
(which is why the files are so big) TIFFs are also extremely flexible in terms
ja
of colour
3) JPEG (also known as JPG): JPEG stands for Joint Photographic Experts Group,
which created this standard for this type of image formatting.
an
- JPEG files are images that have been compressed to store a lot of information
in a small size file.
- Most digital cameras store photos in JPEG format, because then you can take
it
more photos on one camera card than you can with other formats. A JPEG is
G
compressed in a way that loses some of the image detail during the
compression in order to make the file small (and thus called “lossy”
compression).
- JPEG files are usually used for photographs on the web, because they create a
small file that is easily loaded on a web page and also looks good.
4) GIF (Graphic Interchange Format): This format compresses images but, as
different from JPEG, the compression is lossless (no detail is lost in the
compression, but the file can’t be made as small as a JPEG).
- This format is never used for photography, because of the limited number of
colours. GIFs can also be used for animations.
5) PNG (Portable Network Graphics): It was created as an open format to replace
GIF, because the patent for GIF was owned by one company and nobody else
wanted to pay licensing fees. - It also allows for a full range of colour and better
compression. It’s used almost exclusively for web images, never for print
images.
- For photographs, PNG is not as good as JPEG, because it creates a larger
file. But for images with some text, or line art, it’s better, because the images
look less “bitmappy.”
Image resolution:
1. Spatial resolution: It depends on the numbers of pixels. The principal factor
determining spatial resolution is sampling.
2. Grey level Resolution: It depends on number of grey levels. Smallest discernible
changes in grey level.
ar
nk
Colour models:
1. RGB models:
ao
This is an additive model, i.e. the colours present
in the light add to form new colours, and is
appropriate for the mixing of coloured light for
g
example. Red, green and blue are primary colors
to form the three secondary colours yellow (red +
or
green), cyan (blue + green) and magenta (red +
blue), and white ((red + green + blue).
K
2. CMY model:
li
Y=1-B
To save cost on ink, and to produce deeper black tones, unsaturated and black
G
colors are produced by using black ink instead of combination of cyan, magenta
and yellow.
3. HIS Model:
Hue: Dominant colour observe by observer
Intensity: Amount of white color mixed with Hue.
Saturation: Amount of brightness reflection.
ar
nk
g ao
or
K
li
ja
necessary for B&W TV). I and Q gives Chromaticity. The conversion from
RGB to YIQ is given by
it
G
The advantage of this model is that more bandwidth can be assigned to the Y-
component (luminance) to which the human eye is more sensible than to
color information.
ar
outside the image if (x, y) is on the
border of the image.
nk
Adjacency:
- Two pixels are connected if they are neighbours and their grey levels are satisfy
ao
some specified criteria of similarity.
- For example, in a binary image two pixels are connected if they are 4-neighbors
and have same value (0/1).
g
- Let V be set of gray levels values used to define adjacency
or
4-adjacency: Two pixels p and q with values from V are 4- adjacent if q is in the set
K
N4(p)
li
8-adjacency: Two pixels p and q with values from V are 8- adjacent if q is in the set
ja
N8(p).
an
m-adjacency: Two pixels p and q with values from V are m- adjacent if,
it
i)q is in N4(p)
G
connectivity:
- To determine whether the pixels are adjacent in some sense. Let V the set of grey
level values used to define connectivity then two pixels p & q that have values from
the set v are:
4 connected: if q is in set of N4(p)
8 connected: if q is in set of N8(p)
m-connected: if
i) q is in set of N4(p)
ii)q is in ND(p) and the set [N4(p) Ո N4(q)] is empty
Here V= ( 1,2)
ar
nk
g ao
or
K
li
present in the linage. Hence Spatial resolution depends on the Sampling. Spatial
resolution can be defined as is the smallest discernible detail in an image.
an
Intensity resolution which is also known as Gray level resolution or Tonal resolution
is indicative of the number of grey levels that are present in the image. Hence
it
Intensity resolutiondepends on the number of bits used to represent the image and
can be defined as the smallest discernible change in gray level.
G
2) City block distance (D4 distance): If p and q are the two pixels with
coordinates(x1,y1) and (x2,y2) then
D(city) = D(p,q) = │ x1-x2 │ + │ y1-y2 │
3) Chess Board Distance (D8 Distance):
If p and q are the two pixels with coordinates(x1,y1) and (x2,y2) then
D8(p,q) =Max( │ x1-x2 │ , │ y1-y2 │)
4) Dm Distance: This distance is measured based on m adjacency. Pixel p and q are
m adjacent ifi) q is in set of N4(p)
ii)q is in ND(p) and the set [N4(p) I N4(q)] is empty
Example : Let V = {0,1}. Compute DE, D4 ,D8, Dm distance between two pixels p
and q let the pixel coordinates of p and q be (3,0) and (2,3) respectively for the
image shown. Find distance measures.
ar
nk
Solution:
g ao
or
V = {0,1} implies that the distance traversed can pass through 0 and 1.
K
li
ja
an
it
G
ar
and q.
nk
g ao
or
K
Solution:
li
=3
G
nk
Image Enhancement in Spatial Domain:
Image enhancement is one of the first steps in image processing. As the name
ao
suggests, in this technique, the original image is processed so that the
resultant image is more suitable than the original for specific applications i.e.
the image is enhanced. Image enhancement is a purely subjective processing
g
technique. By subjective we mean that the desired result varies from person
or
to person. An image enhancement technique used to process images might be
excellent for a person, but the same result might not be good enough for
another. It is also important to know at the outset that image enhancement is a
K
cosmetic procedure i.e. it does not add any extra information to the original
image. It merely improves the subjective quality of the images by working
with the existing data Image enhancement can be done in two domains :
li
image. It implies working with the pixel values or in other words, working
directly with the raw data.
G
Let f(x. y) be the original image where f is the grey level value and (x. y) are
the image coordinates. For a 8-bit image, f can take values from 0 - 255
where 0 represents black, 255 represents white and all the intermediate values
represent shades of grey. In a image of size 256 x 256. x and y can take
values from (0,0) to (255,255) as shown below
Point Processing:
ar
In point processing, we work with single pixels i.e. T is 1 x 1 operator. It
means that the new value f(x. y) depends on the operator T and the present
nk
f(x, y). This statement will be clear as we start giving some examples.
In the Fig., the solid line is the transformation T. The horizontal axis
represents the grey scale of the input image (r) and the vertical axis represents
ao
the grey scale of the output image (s). It is called an identity transformation
because it does not modify the new image at all !!. As seen, the grey level 10
is modified to 10.125 to 125 and finally 255 to 255. In general s1=r1 ,below
g
Fig. will help us to understand point processing techniques better.
or
K
li
ja
an
it
G
s = T(r)
r = input pixel
Intensity
s = output pixel
Intensity
T is a function
ar
1) Digital Negative:
Digital negatives are useful in a lot of applications, common example of
nk
digital negative is the displaying of an X-i image As the name suggests,
negative simply means inverting i grey levels i.e. black in the original image
will now look white a vice versa. The Fig. is the digital negative
ao
transformation for 8-bit image.
g
or
K
li
ja
projecting the negative onto the paper with a photographic enlarger or making
a contact print.
2. Contrast Stretching :
Fig. a) Form of T function b) Low Contrast Image c) Contrast Stretching d)
ar
Threshold function
- The Contrast stretching is used to increase the contrast of image by making the
nk
dark portions darker and bright portions brighter.
g ao
- We make dark area darker by assigning a slope less than 1 & make bright area
or
brighter by assigning a slope greater than 1.
K
3. Thresholding
∙ Extreme contrast is known as Thresholding.
li
ja
an
it
G
-Thresholding has only 2 values, black or white.( Threshold image has maximum
contrast). In thresholding, we convert an image from color or grayscale into a
binary image, i.e., one that is simply black and white. Most frequently, we use
thresholding as a way to select areas of interest of an image, while ignoring the
parts we are not concerned with.
4. Grey Level Slicing (Intensity Slicing)
- When we have to highlight a specific range of grey value like enhancing the flaws
in x ray or CT image for that we have to use a transformation is known as Grey
Level Slicing.
(Without background)
This method is known as Grey level slicing without background. This is because in
ar
this process, we have completely lost the background.
(With background)
nk
In some applications, we not only need to enhance a band of grey levels but also
need to retain the background. This technique of retaining the background is called
ao
as Grey-level slicing with background.
g
or
K
- In Bit Plane Slicing, we have to consider particular bit of pixel and draw an image.
- Suppose make image of only LSB, only MSB like total 8 different images. - All 8
images will be binary.
- Observing the images we come to conclusion that the higher order bits contain majority of
visually significant data, while the lower bits contain the suitable details in the image.
- Bit Plane Slicing used for an image compression, we can remove lower order bits and
transmit only higher order bits.
ar
nk
ao
g
or
K
li
ja
an
it
G
6. Dynamic Range Compression (Log Transformation)
- Dynamic range of the image exceeds the capability of the display devices. -
Some images have pixels with high value (intensity) and some images with low
value. So, we cannot see the low value pixels in the image. For example, in day
time we cannot see stars because sun has high intensity compare with stars so
that the eye cannot adjust to such a large dynamic range.
Dynamic range refers to the ratio of max and min intensity values. When the
dynamic range of the image is greater than that of displaying device(like in
Fourier transform), the lower values are suppressed. To overcome this issue, we
ar
use log transform. Log transformation first compresses the dynamic range and
then upscales the image to a dynamic range of the display device. In this way,
nk
lower values are enhanced and thus the image shows significantly more details.
Applications:1) Expands the dark pixels in the image while compressing the
ao
brighter pixels.2) Compresses the dynamic range (display of Fourier transform).
pixel values at the expense of loss of information in the high pixel values.
an
Be careful, if most of the details are present in the high pixel values, then
applying the log transform results in the loss of information as shown below
it
G
7. Power Law Transformation
Formula
ar
nk
g ao
or
But the main question is why we need this transformation, what’s the benefit of
K
doing so?
To understand this, we first need to know how our eyes perceive light. The
li
See from the above figure, if we change input from 0 to 10, the output changes
from 0 to 50 (approx.) but changing input from 240 to 255 does not really
change the output value. This means that we are more sensitive to changes in
dark as compared to bright. You may have realized it yourself as well!
But our camera does not work like this. Unlike human
perception, camera follows a linear relationship. This means that if light falling
on the camera is increased by 2 times, the output will also increase 2 folds. The
camera curve looks like this
ar
nk
g ao
or
So, where and what is the actual problem?
The actual problem arises when we display the image.You might be amazed to
K
know that all display devices like your computer screen have Intensity to voltage
response curve which is a power function with exponents(Gamma) varying from
1.8 to 2.5.
li
This means for any input signal(say from a camera), the output will be
ja
To correct this, we apply gamma correction to the input signal(we know the
intensity and voltage relationship we simply take the complement) which is
known as Image Gamma. This gamma is automatically applied by the
conversion algorithms like jpeg etc. thus the image looks normal to us.
This input cancels out the effects generated by the display and we see the image
as it is. The whole procedure can be summed up as by the following figure
ar
nk
If images are not gamma-encoded, they allocate too many bits for the bright
tones that humans cannot differentiate and too few bits for the dark tones. So, by
ao
gamma encoding, we remove this artifact.
Images which are not properly corrected can look either bleached out, or too
dark.
g
or
Non-linearities encountered during image capturing, printing and displaying can
be corrected using gamma correction Hence gamma correction is important if
the image needs to be displayed on the computer The power law transformation
K
Example: Obtain the digital negative of following 8 bits per pixel image
ja
134 50 38 99 104
116 128 98 138 130
28 73 77 58 13
54 149 136 4 15
ar
Example: For a given image find: 1) Digital Negative of an image. 2) Bit Plane
Slicing.
nk
4 3 2 1
ao
3 1 2 4
5 1 6 2
g
or
2 3 5 6
Digital Negative
K
𝑆(𝑥,𝑦)=7−𝑟(𝑥,𝑦)
4 6 5 3
an
2 6 1 5
it
5 4 2 1
G
ar
nk
Example : For following image find Contrast Stretching
ao
r2 = 5 , r1 = 3 , s2 = 6 , s1 = 2
g
or
K
li
ja
2 1 1 4
2 0.66 1.32 4
K
6 1 7 1
6 0.66 6.5 1.32
1 2 6 7
li
1.32 2 6 6.5
ja
1 2 3 0
G
2 4 6 7
5 2 4 3
3 2 6 1
ar
nk
g ao
or
K
li
Histogram :
ja
an
occurrences of grey levels in image against with grey level values. It provides
more information about brightness & contrast of image.
Histogram of dark image will be clustered towards lower grey levels.
Histogram of bright image will be clustered towards higher grey levels.
For low contrast image the histogram will not be spread equally, that is, the
histogram will be narrow.
For high contrast image the histogram will have an equal spread in the grey
level. Image brightness may be improved by modifying the histogram of the
image.
Histogram of an image can be plotted in two ways. In the first method, the x-
axis has the grey levels and the y-axis has the number of pixels in each grey
level, while in the second method, the x-axis represents the grey levels, while
the y-axis represents the probability of the occurrence of that grey level.
Method 1:
Grey level No of pixels
0 40
ar
1 20
2 10
nk
3 15
4 10
ao
5 3
6 2
g
or
K
li
ja
Method 2:
an
0 40 0.40
1 20 0.20
2 10 0.10
3 15 0.15
4 10 0.10
5 3 0.03
6 2 0.02
n = 100
ar
This is known as a normalised histogram. The advantage of the second method
nk
is that the maximum value to be plotted will always be 1. Generally black is
considered as grey level 0 and white as the maximum. Just by looking at the
histogram of the image, a great deal of information can be obtained. Some of the
ao
typical histograms are shown in Fig.
g
or
K
li
ja
an
it
G
ar
nk
g ao
or
K
li
ja
an
In fig a all the pixels belong to the lower grey levels 0,1,.... and hence we can be
it
sure that the image, represented by this histogram, is a dark image. Similarly.
Fig b is the histogram of a bright image. Fig.c is a low contrast image since only
G
a small range of grey levels are present. Fig.d is a high contrast image. Of all the
4 histograms shown, the last histogram represents the best image.
Histogram stretching :
- One way to increase dynamic range of histogram this technique is known as
histogram stretching.
- In this histogram is spread over entire dynamic range.
Where smax= Maximum grey level of output image
smin = Minimum grey level of output image
rmax = Maximum grey level of input image
rmin=Minimum grey level of input image
Example: Perform histogram stretching on the following image. So that new image has dynamic
range [0,7].
ar
nk
Solution:
Here,
rmin = 2
g ao
or
rmax = 6
smax = 0
K
smin = 7
li
ja
an
it
Modified Histogram:
G
ar
nk
Histogram Equalization :
ao
There are many applications, wherein we need a Hat histogram. This cannot be
achieved by histogram stretching. We now introduce a new technique known as
histogram equalization. A perfect image is one which has equal number of
g
pixels in all its grey levels. Hence our objective is not only to spread the
dynamic range, but also to have equal pixels in all the grey levels. This
or
Example: Perform histogram equalization on the following image histogram. Plot the
original and equalized histogram.
Gray 0 1 2 3 4 5 6 7
Levels
No.of 790 1023 850 656 329 245 122 81
Pixels
Solution:
ar
0 790 0.19 0.19 1.33 1 1
nk
2 850 0.21 0.65 4.55 5 5
ao
3 656 0.16 0.81 5.67 6 6
7 81 0.02 1 7 7 7
li
n=
ja
4096
an
gray 0 1 2 3 4 5 6 7
level(s)
it
=985 48
Pixels
ar
nk
Example: consider given image and find out equalized histogram
ao
F(x,y)=
g
4 4 4 4 4
or
3 4 5 4 3
K
3 5 5 5 3
li
3 4 5 4 3
ja
4 4 4 4 4
an
it
Solution:
G
Gray Levels 0 1 2 3 4 5 6 7
No.of Pixels 0 0 0 6 14 5 0 0
1 0 0 0 0 0 0
2 0 0 0 0 0 0
ar
5 5 0.20 1 7 7 7
nk
6 0 0 1 7 7 7
7 0 0 1 7 7 7
n =25 g ao
or
Gray 0 1 2 3 4 5 6 7
Levels
K
No.of 0 0 6 0 0 0 14 5+0+0=5
Pixels
li
ja
an
it
G
ar
nk
g ao
or
K
li
ja
an
Histogram specification:
From the earlier method (Histogram equalization) we note that histogram
equalization is automatic. It is not interactive, i.e., it always gives one result - an
it
interactive method in which certain grey level are highlighted. It should be noted
that if we modify the grey level of an image that has a uniform PDF, p,(s), using
the inverse transformation r = T'(s), we get back the original histogram p,(r).
Exploiting this knowledge, we can obtain any shape of the grey % level
histogram by processing the given image in the following way. Suppose pr(r)
and p,(s) represent grey level PDFs of input and output images and r and s are
their respective grey levels. Suppose k represents grey level of some
intermediate image result i.e.,
The procedure of histogram specification can be computed as follows:
(1) Equalize the levels of the original image.
(2) Specify the desired density function and obtain the transformation function.
(3) Apply the inverse transformation function.
Example: Given histogram (a) and (b) modify histogram (a) as given (b).
Histogram (a):
ar
Gray 0 1 2 3 4 5 6 7
Levels
nk
No.of 790 1023 850 656 329 245 122 81
ao
Pixels
Histogram (b):
Gray
g 0 1 2 3 4 5 6 7
Levels
or
Pixels
Off
level.(r) level.(s)
an
n=
4096
gray 0 1 2 3 4 5 6 7
level(s)
ar
No.of 0 0 1023 0 850 656+329 245+122+
790 =985 81=448
Pixels
nk
Now equalized histogram (b):
Grey nk Pr(k) = Sk=∑ Pr(k) (L-1) Sk Rounding
ao
level.(r) g nk/n Off
0 0 0 0 0 0
or
1 0 0 0 0 0
K
2 0 0 0 0 0
7 614 0.15 1 7 7
G
n = 4096
Applying inverse transform and comparing histogram (a) and histogram (b).
gray 01 2 3 4 5 6 7
level(s)
ar
1. Contrast starching as per the characteristics given in
fig
nk
2. Draw original and new histogram
1. Equalize the histogram
10 2 13 7
11
4
14
7
g 6
3
ao9
2
or
0 5 10 7
K
li
ja
an
it
G
ar
nk
12 0.8 13.8 6 12 1 14 6
ao
12.6 14.4 4 10 13 14 4 10
S(x,y) =
1.6 6 1.2 0.8 2 6 1 1
g
or
0 2 12 6 0 2 12 6
2)
K
li
ja
an
it
G
3)
Grey nk Pr(k) = Sk=∑ Pr(k) (L-1) Sk Rounding Grey
Off
level.(r) nk/n level.(s)
ar
6 1 0.067 0.402 6.03 6 6
nk
7 3 0.2 0.602 9.03 9 9
8 0 0 0.602 9.03 9 9
10
1
2
0.067
0.13
0.669
0.799
g10.035
11.985
ao
10
12
10
12
or
12 0 0 0.866 12.99 13 13
13 1 0.067 0.933 14 14 14
li
ja
14 1 0.067 1 15 15 15
15 0 0 1 15 15 15
an
n =15
it
G
grey 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
levels
No of 0 1 1 1 1 1 1 0 0 3 1 0 2 1 1 1
pixels
Question: Continuous image histogram can be perfectly equalized but it may not
be so for digital image.
ar
Solution: This statement is true.
- The cumulative density function ensures that we get a flat histogram is the
nk
continuous domain.
- The discrete domain, as we are aware is an approximation of the continuous
domain i.e. values between integers values are not known because of which
ao
redistribution takes place.
- For example values such as 1.1, 1.2, and 1.3, are all grouped together and
placed in value 1. Due to this perfectly flat histograms are never obtained in the
g
discrete domain.
Question: Difference between Histogram and Contrast Stretching.
or
values of all pixels in the image as between the minimum and maximum
equally. intensity value in image.
li
3. It is reliable. 3. It is unreliable.
4. It is non-linear normalization. 4. It is linear normalization.
5. In histogram equalization, the original 5. In contrast stretching, the original
it
image cannot be restored from equalized image can be restored from contrast
image. stretched image
G