Beruflich Dokumente
Kultur Dokumente
0,0 0, 1
1,0
1, 1
Each element of the array is called a pixel or a pel derived from the term "picture element". Each
pixel represents not just a point in the image but rather a rectangular region, the elementary cell
of the grid. The position of the pixel is given in the common notation for matrices. The first
index, m, denotes the position of the row, the second, n, the position of the column. If the digital
image contains M ×N pixels, i.e., is represented by an M ×N matrix, the index n runs from 0 to
N-1,and the index m from 0 to M-1. M gives the number of rows, N the number of columns.
1
Figure 1.1: Representation of digital images by arrays of discrete points on a rectangular grid
How many pixels are sufficient? There is no general answer to this question. For visual
observation of a digital image, the pixel size should be smaller than the spatial resolution of the
visual system from a nominal observer distance. For a given task the pixel size should be smaller
than the finest scales of the objects that we want to study.
2
Figure 1.2: The figure shows the same image with a 3 × 4, b 12 × 16, c 48 × 64, and d 192× 256
pixels. If the image contains sufficient pixels, it appears to be continuous.
1.2.2 Resolution
The number of pixels packed into a unit of measure [e.g. inch] that determines the quality of the
image. This value is the image resolution. Image resolution most commonly refers to the number
of pixels per inch. This is called “dots per inch,” or dpi. In most cases, higher resolution [higher
dpi] results in better image quality. Remember, however, that final image quality is limited by
the quality of your image source. While image resolution can always be reduced, increasing
resolution will not improve image quality.
3
1.2.3 Bit-depth
Bit-depth refers to the number of bits assigned to a single pixel and determines the number of
colors from which a particular pixel value can be selected. Where a bit is the lowest level of
electronic value in a digital image, defines a pixel’s color value in combination with other bits.
Each bit can have one of two values: 1 or 0. For example A one-bit image can assign only one of
two values to a single pixel: 1 or 0 (black or white). An 8-bit grayscale image can assign one of
256 (28) colors to a single pixel. A 24-bit RGB image (8-bits each for red, green and blue color
channels) can assign one of 16.8 (224) million colors to a single pixel.
1) Binary:-Each pixel is just black or white. Since there are only two possible values for each
pixel, we only need one bit per pixel. Such images can therefore be very efficient in terms of
storage. Images for which a binary representation may be suitable include text (printed or
handwriting), fingerprints, or architectural plans.
4
2) Grayscale:-. Each pixel is a shade of grey, normally from 0 (black) to) 255 (white). This range
means that each pixel can be represented by eight bits, or exactly one byte. This is a very natural
range for image _le handling. Other grayscale ranges are used, but generally they are a power of
2. Such images arise in medicine (X-rays), images of printed works, and indeed 256 different
grey levels is sufficient for the recognition of most natural objects.
3) True color or RGB: Here each pixel has a particular color; that color being described by the
amount of red, green and blue in it. If each of these components has a range 0-255 this gives a
total of 2553 =16,777,216 different possible colors in the image. This is enough colors for any
image. Since the total number of bits required for each pixel is 24, such images are also called
24-bit color images. Such an image may be considered as consisting of a “stack” of three
matrices; representing the red, green and blue values for each pixel. This means that for every
pixel there correspond three values.
5
Figure 1.4: A true color image
6
differ in the number of colors they contain. If an image has few colors, a file type can be
designed to exploit this as a way of reducing file size.
1) TIFF (Tagged Image File Format): It is a very flexible format that can be lossless or lossy.
The details of the image storage algorithm are included as part of the file. In practice, TIFF is
used almost exclusively as a lossless image storage format that uses no compression at all. Most
graphics programs that use TIFF do not compress. Consequently, file sizes are quite big.
2) PNG (Portable Network Graphics): It is also a lossless storage format. However, in contrast
with common TIFF usage, it looks for patterns in the image that it can use to compress file size.
The compression is exactly reversible, so the image is recovered exactly.
3) GIF (Graphics Interchange Format): It creates a table of up to 256 colors from a pool of 16
million. If the image has fewer than 256 colors, GIF can render the image exactly. When the
image contains many colors, software that creates the GIF uses any of several algorithms to
approximate the colors in the image with the limited palette of 256 colors available. Better
algorithms search the image to find an optimum set of 256 colors.
4) JPG (Joint Photographic Experts Group): It is optimized for photographs and similar
continuous tone images that contain many, colors. It can achieve astounding compression ratios
even while maintaining very high image quality. GIF compression is unkind to such images. JPG
works by analyzing images and discarding kinds of information that the eye is least likely to
notice. It stores information as 24 bit color.
5) Camera RAW: It is a lossless compressed file format that is proprietary for each digital
camera manufacturer and model. A camera RAW file contains the 'raw' data from the camera's
imaging sensor. Some image editing programs have their own version of RAW too. However,
camera RAW is the most common type of RAW file. The advantage of camera RAW is that it
contains the full range of color information from the sensor. This means the RAW file contains
12 to 14 bits of color information for each pixel.
7
CHAPTER 2
IMAGE ENHANCEMENT
8
transform operations as in discrete Fourier transform; and other operations as in pseudo-coloring
where a gray level image is mapped into a color image by assigning different colors to different
features.
An important issue in image enhancement is quantifying the criterion for enhancement. Many
image enhancement techniques are empirical and require interactive procedures to obtain
satisfactory results.
s = T(r) (2.1)
Where T is a transformation that maps a pixel value r into a pixel value s. The results of this
transformation are mapped into the grey scale range as we are dealing here only with grey scale
digital images.
In spatial domain techniques, we directly deal with the image pixels. The pixel values are
manipulated to achieve desired enhancement. In frequency domain methods, the image is first
transferred in to frequency domain. It means that, the Fourier Transform of the image is
computed first. All the enhancement operations are performed on the Fourier transform of the
image and then the Inverse Fourier transform is performed to get the resultant image. These
enhancement operations are performed in order to modify the image brightness, contrast or the
distribution of the grey levels. As a consequence the pixel value (intensities) of the output image
will be modified according to the transformation function applied on the input values.
9
CHAPTER 3
HISTOGRAM EQUALIZATION
10
The histogram gives primarily the global description of the image. For example, if the image
histogram is narrow, then it means that the image is poorly visible because the difference in gray
levels present in the image is generally low. Similarly a widely distributed histogram means that
almost all the gray levels are present in the image and thus the overall contrast and visibility
increases. The shape of the histogram of an image reveals important contrast information, which
can be used for image enhancement.
0,1, … , 1 3.1.2
where M and N are the row and column dimension of the image, consequently n=MN is the total
number of pixel in the image.
The function represents the fraction of the total number of pixels with gray value . It
gives a measure of how likely is for a pixel to have a certain gray value.That is, it gives the
probability of occurrence the intensity.The sum of the normalised histogram function over the
range of all gray values is 1.
If we consider the gray values in the image as realizations of a random variable R, with some
probability density, normalised histogram provides an approximation to this probability density.
In other words,
Four basic image types: dark, light, low contrast, high contrast, and their corresponding
histograms are given below.
12
Figure 3.3: A bright image and its histogram
13
.
14
that produce a level s for every pixel value r in the original image. For reasons that will become
obvious shortly, we assume that the transformation function T(r) satisfies the following
conditions:
(a) T(r) is single-valued and monotonically increasing in the interval 0 ≤ r ≤ L-1; and
The requirement in condition (a) that T(r) be monotonically increasing guarantees that output
intensities values will never be less than the corresponding input values thus preventing artifacts
created by reversals of intensity. Condition (b) guarantees that the range of output intensities is
the same as input. Following figure gives an example of a transformation function that satisfies
these two conditions.
It can be shown that even if T(r) satisfies conditions (a) and (b), it is possible that the
corresponding inverse may fail to be single valued.
15
The gray levels in an image may be viewed as random variables in the interval [0, 1]. One of the
most fundamental descriptors of a random variable is its probability density function (PDF). Let
' and ( denote the probability density functions of random variables r and s,
respectively, where the subscripts on p are used to denote that ' and ( are different functions .A
basic result from an elementary probability theory is that, if ' and T(r) are known and
satisfies condition (a), then the probability density function ( of the transformed variable s
can be obtained using a rather simple formula.
*
( ' ) ) 3.3.3
*
Thus, the probability density function of the transformed variable, s, is determined by the
gray-level PDF of the input image and by the chosen transformation function.
'
! 1 +- ' , *, (3.3.4)
where w is a dummy variable of integration. The right side of Eq. (3.3.4) is recognized as the
cumulative distribution function (CDF) of random variable r. Since probability density functions
are always positive, and recalling that the integral of a function is the area under the function, it
follows that this transformation function is single valued and monotonically increasing, and,
therefore, satisfies condition (a). When the upper limit in this equation is r = (L-1) the integral
evaluates to 1(the area under a PDF curve always is 1), so the maximum value of s is (L-1) and
condition (b) is satisfied also.
To find the ( corresponding to the transformation just discussed we use equation (3.3.3).
We know from basic calculus (Leibniz’s rule) that the derivative of a definite integral with
respect to its upper limit is simply the integrand evaluated at that limit.
In other words,
* *!
* *
* '
1 ./ ' , *,0
* -
1' 3.3.5
Substituting this result for dr/ds into Eq. (3.3.3), and keeping in mind that all probability values
are positive, yields
16
*
( ' ) )
*
1
' ) )
1'
1
0" " 1 3.3.6
1
We recognize the form of p4 s given in Eq. (3.3.6) as a uniform probability density function.
Simply stated, we have demonstrated that performing the transformation function given in Eq.
(3.3.4) yields a random variable s characterized by a uniform probability density function. It is
important to note from Eq. (3.3.4) that T(r) depends on p5 r, but, as indicated by Eq. (3.3-6), the
resulting p4 s always is uniform, independent of the form p5 r
For discrete values we deal with probabilities and summations instead of probability density
functions and integrals. The probability of occurrence of gray level in an image is
approximated by
!
1 7 ' 89 :
9;-
1
7 9 0,1, … , 1 3.3.8
9;-
Thus, a processed (output) image is obtained by mapping each pixel with level r= in the input
image into a corresponding pixel with level s= in the output image via Eq. (3.3.8). As indicated
earlier, a plot of p5 r= versus r= is called a histogram. The transformation (mapping) given in
Eq. (3.3-8) is called histogram equalization.
Unlike its continuous counterpart, it cannot be proved in general that this discrete transformation
will produce the discrete equivalent of a uniform probability density function, which would be a
uniform histogram. However, as will be seen shortly, use of Eq. (3.3.8) does have the general
tendency of spreading the histogram of the input image so that the levels of the histogram
equalized image will span a fuller range of the gray scale.
17
3.3.2 A Numerical Example of Histogram Equalization.
Suppose a 4-bit grayscale image has the histogram shown in figure associated with a table of the
numbers n? of grey values:
Gray level i 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
n? 15 0 0 0 0 0 0 0 0 70 110 45 80 40 0 0
With n=MN=360 and L=16, we would expect this image to be uniformly bright, with a few dark
dots on it. To equalize this histogram, we form running totals of the n? , and multiply each by
15/360 =1/24.
18
Gray level i n? ∑ A (1/24) ∑ A Rounded value
0 15 15 0.63 1
1 0 15 0.63 1
2 0 15 0.63 1
3 0 15 0.63 1
4 0 15 0.63 1
5 0 15 0.63 1
6 0 15 0.63 1
7 0 15 0.63 1
8 0 15 0.63 1
9 70 85 3.65 4
10 110 195 8.13 8
11 45 240 10 10
12 80 320 13.33 13
13 40 360 15 15
14 0 360 15 15
15 0 360 15 15
We now have the following transformation of grey values, obtained by reading of the first and last
columns in the above table:
The histogram of the values is shown in figure 3.8. This is far more spread out than the original
histogram, and so the resulting image should exhibit greater contrast.
19
3.3.3 Results of Histogram
istogram Equalization
We have the following dark image.
20
CHAPTER 4
HISTOGRAM MATCHING
As indicated in the preceding chapter, histogram equalization automatically determines a
transformation function that seeks to produce an output image that has a uniform histogram.
When automatic enhancement is desired, this is a good approach because the results from this
technique are predictable and the method is simple to implement. We show in this chapter that
there are applications in which attempting to base enhancement on a uniform histogram is not the
best approach. In particular, it is useful sometimes to be able to specify the shape of the
histogram that we wish the processed image to have. This can be accomplished by specifying a
particular histogram shape, or by calculating the histogram of a target image. The method used to
generate a processed image that has a specified histogram is called histogram matching or
histogram specification.
'
! 1 / ' , *, 4.1.1
-
B
E F C 1 / B G *G 4.1.2
-
21
where t is a dummy variable of integration. It then follows from these two equations that
G(z)=T(r) and, therefore, that z must satisfy the condition
C F #$ H!I F #$ 4.1.3
The transformation T(r) can be obtained from Eq. (4.1.1) once ' has been estimated from the
input image. Similarly, the transformation function G(z) can be obtained using Eq. (4.1.2)
because B C is given.
Equation (4.1.1) through (4.1.2) shows that an image whose intensity levels have a specified
probability density function can be obtained from a given image by using the following
procedure.
1) Obtain ' from the input image and use Eq. (4.1.1) to obtain the values of s
2) Use the specified probability density function in equation (4.1.2) to obtain the
transformation function G(z).
4) Obtain the output image by first equalizing the input image using Eq.(4.4.1); the pixel
values in this image are the s values. For each pixel with value s in equalized image,
perform the inverse mapping C F #$ to obtain the corresponding pixel values in
output image. When all pixels have been thus processed, the probability density function
of the output image will be equal to the specified probability function.
22
The discrete formulation of Eq. (4.1.1) is
!
1 7 ' 89 :
9;-
1
7 9 0,1, … , 1 4.1.4
9;-
Where as before, MN is the total number of pixels in the image, 9 is the number of pixels that
have intensity value 9 and L is the total number of possible intensity levels in the image.
Similarly, given a specific value of , the discrete formulation of Eq. (4.1.2) involves
computing the transformation function
F8CJ : 1 7 B CA
A;-
J
1
7 A K 0,1, … , 1 4.1.5
A;-
F8CJ : 4.1.6
where B CA is the ith value of specified histogram. We find the desired value CJ by obtaining
the inverse transformation:
CJ F #$ 4.17
In other words, this operation gives a value of z for each value of s, thus it performs a mapping
from s to z
23
4.2 Algorithm for histogram specification
1) Compute the histogram ' of the given image and use it to find the histogram
equalization transformation in Eq. (4.1.4). Round the resulting values, , to the integer
range [0,L-1].
2) Compute all values of the transformation function G using the Eq. (4.1.5) for
q = 0, 1,… L-1, where B CA are the value of specified histogram. Round the values of G
to integers in the range [0, L-1]. Store the values of G in a table.
3) For every value of ,k =0, 1, …, L-1, use the stored value of G from step 2 to find the
corresponding value of CJ so that F8CJ : is closest to and store these mappings from s
to z . When more than one value of CJ satisfies the given (i.e. the mapping is not
unique), choose the smallest value by convention.
4) From the histogram specified image by first histogram-equalizing the input image and
then mapping every equalized pixel values, , of this image to the corresponding value
CJ in the histogram specified image using the mappings found in step 3.
Gray level r= 0 1 2 3 4 5 6 7
n= 790 1023 850 656 329 245 122 81
It is desired to transform this histogram so that it will have the value specified in the following
Gray level zN 0 1 2 3 4 5 6 7
nN 0 0 0 614 819 1230 819 614
24
First we compute the scaled histogram equalized values for input image like as follows
Next we compute the values of the transformation function, G, using Eq. (4.1.5)
In the third step of the procedure we find the smallest value of zN so that the value
FCJ is the closest to s= . We do this every value of s= to create the required mapping from s to
z. For example, s- =1 , and we see that F CO 1, which is a perfect match in this case, so we
have the correspondence s- P CO . That is every pixel whose value is 1 in the histogram
equalized image would map to a pixel valued 3 (in the corresponding location) in the histogram
specified image. Continuing in this manner we get the following mapping.
s= 1 3 5 6 7
zN 3 4 5 6 7
In the final step of procedure we use above mapping to map every pixel in the histogram
equalize image into a corresponding pixel in the newly created histogram specified image.
25
r= 0 1 2 3 4 5 6 7
s= 1 3 5 6 6 7 7 7
z= 3 4 5 6 6 7 7 7
r= 0 1 2 3 4 5 6 7
n= 0 0 0 790 1023 850 985 448
We see, the actual histogram of the output image does not exactly but only approximately
matches with the specified histogram. This is because we are dealing with discrete histograms.
26
Histogram equalized image of input image and its histogram are given below. We see histogram
equalized image is not very satisfactory for visual perception.
Now we try to match the histogram of input image with following specified histogram
27
Histogram specified image of input image and its histogram are given below. We see histogram
specified image is better than histogram equalized image.
28
CHAPTER 5
Histogram equalization is useful in images with backgrounds and foregrounds that are both
bright or both dark. In particular, the method can lead to better views of bone structure in x-ray
images, and to better detail in photographs that are over or under-exposed. A key advantage of
the method is that it is a fairly straightforward technique and an invertible operator. So in theory,
if the histogram equalization function is known, then the original histogram can be recovered.
The calculation is not computationally intensive. A disadvantage of the method is that it is
indiscriminate. It may increase the contrast of background noise, while decreasing the usable
signal.
29