Instant Download (Ebook) Modern Algorithms for Image Processing: Computer Imagery by Example Using C# by Vladimir Kovalevsky ISBN 9781484242360, 148424236X PDF All Chapters
Instant Download (Ebook) Modern Algorithms for Image Processing: Computer Imagery by Example Using C# by Vladimir Kovalevsky ISBN 9781484242360, 148424236X PDF All Chapters
com
https://ebooknice.com/product/modern-algorithms-for-image-
processing-computer-imagery-by-example-using-c-7282956
DOWLOAD EBOOK
ebooknice.com
https://ebooknice.com/product/digital-image-processing-using-
matlab-10945078
ebooknice.com
https://ebooknice.com/product/digital-media-processing-dsp-algorithms-
using-c-1537702
ebooknice.com
https://ebooknice.com/product/digital-image-processing-using-
matlab-r-1273030
ebooknice.com
(Ebook) Essential algorithms : a practical approach to
computer algorithms using Python and C# by Rod Stephens
ISBN 9781119575993, 1119575990
https://ebooknice.com/product/essential-algorithms-a-practical-
approach-to-computer-algorithms-using-python-and-c-12274474
ebooknice.com
ebooknice.com
https://ebooknice.com/product/computer-vision-and-image-analysis-
digital-image-processing-and-analysis-55456502
ebooknice.com
Modern
Algorithms for
Image Processing
Computer Imagery by Example Using C#
—
Vladimir Kovalevsky
Modern Algorithms for
Image Processing
Computer Imagery by Example
Using C#
Vladimir Kovalevsky
Modern Algorithms for Image Processing: Computer Imagery by Example Using C#
Vladimir Kovalevsky
Berlin, Germany
Acknowledgments��������������������������������������������������������������������������������������������������� xi
Introduction����������������������������������������������������������������������������������������������������������� xiii
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
References������������������������������������������������������������������������������������������������������������ 267
Index��������������������������������������������������������������������������������������������������������������������� 269
viii
About the Author
Vladimir Kovalevsky received his diploma in physics from the Kharkov University
(Ukraine), his first doctoral degree in technical sciences from the Central Institute of
Metrology (Leningrad), and his second doctoral degree in computer science from the
Institute of Cybernetics of the Academy of Sciences of the Ukraine (Kiev) where he
headed the Department of Pattern Recognition for more than a decade.
Vladimir has been living in Germany since 1983. He was a researcher at the Central
Institute of Cybernetics of the Academy of Sciences of the GDR, Berlin, a professor
of computer science at the University of Applied Sciences Berlin, and a scientific
collaborator at the University of Rostock.
He has been a visiting researcher at the University of Pennsylvania, a professor at
the Manukau Institute of Technology in New Zealand, and a professor at the Chonbuk
National University in South Korea. He has reviewed for the journals Applied General
Topology, Computer Vision and Image Understanding, IEEE Transactions on Pattern
Analysis and Machine Intelligence, and others.
Vladimir has been a plenary speaker at conferences in Europe, the United States, and
New Zealand. His research interests include digital geometry, digital topology, computer
vision, image processing, and pattern recognition. He has published four monographs
and more than 180 journal and conference papers on image analysis, digital geometry,
and digital topology.
ix
Acknowledgments
I wish to acknowledge valuable and fruitful discussions with Boris Flach, Reinhard
Klette, Ulrich Koethe, Alexander Kovalevsky, Volkmar Miszalok, and Peer Stelldinger.
These discussions have significantly contributed to this work.
I would like to express my special appreciation to Alexander V. Kovalevsky, who
helped significantly as an experienced programmer in the development of my projects.
xi
Visit https://ebooknice.com to
discover a wide range of
eBooks across various genres.
Enjoy exclusive deals and
discounts to enhance your
reading experience. Start your
digital reading journey today!
Introduction
This book presents a collection of algorithms and projects for processing two-dimensional
images. I developed and investigated the algorithms. Special emphasis is placed on
computer solutions of problems related to the improvement of the quality of images,
with image analysis and recognition of some geometrically definable objects. New data
structures useful for image analysis are presented. The description of all algorithms
contains examples of source code in the C# programming language. Descriptions of
projects contain source code that can be used by readers.
With this book I intend to help you develop efficient software for processing
two-dimensional images. There are a lot of books on image processing, but important
algorithms are missing from these books. I have developed many efficient algorithms as
a new and important contribution to this area.
I have paid great attention to solutions of problems in image analysis. On the other
hand, problems of improving the quality of images are important for the arts. My wife is
a recognized specialist in the history of the arts, and her publications often use copies
of famous pictures and drawings. The photographs of these artworks are often of low
quality. Often photographs of historical drawings illustrating the work of a painter are
of such low quality that it is almost impossible to clearly see the contents of the image.
Improving these images is therefore very important. In such cases, the programs I have
developed for improving the quality of pictures are very useful.
I have developed efficient algorithms for recognizing circles and ellipses in
noisy images. These algorithms can be used for recognizing objects with a shape
approximating a circle; for example, apples, mushrooms, and so on. They can also be
used for recognizing bicycles in images of traffic because the wheels of bicycles are ideal
circles, but if the bicycle is positioned in such a way that the plane of its frame is not
orthogonal to the viewing ray, then its wheels look like ellipses rather than circles. I was
therefore forced to develop efficient algorithms for recognizing ellipses in noisy images
as well. My efforts were successful and the book contains a chapter devoted to the
recognition of bicycles in noisy images.
The book contains descriptions of numerous algorithms for image analysis,
including these:
xiii
Introduction
Among the algorithms for image improvement, the most important are the following:
xiv
PART I
Image Processing
CHAPTER 1
Introduction
This book contains descriptions of algorithms for image processing such as noise
reduction, including reduction of impulse noise, contrast enhancement, shading
correction, edge detection, and many others. The source codes of the projects in the
C# programming language implementing the algorithms are included on the book’s
companion web site. The source codes are Windows Forms projects rather than
Microsoft Foundation Classes Library (MFC) projects. The controls and the graphics in
these projects are implemented by means of simple and easily understandable methods.
I have chosen this way of implementing controls and graphics services rather than those
based on MFC because the integrated development environment (IDE) using MFC is
expensive. Besides that, the software using MFC is rather complicated. It includes many
different files in a project and the user is largely unable to understand the sense and
usefulness of these files. On the contrary, Windows Forms and its utility tools are free
and are easier to understand. They supply controls and graphics similar to that of MFC.
To provide fast processing of images we transform objects of the class Bitmap, which
is standard in Windows Forms, to objects of our class CImage, the methods of which are
fast because they use direct access to the set of pixels, whereas the standard way of using
Bitmap consists of implementing the relatively slow methods of GetPixel and SetPixel
or methods using LockBits, which are fast, but not usable for indexed images.
The class CImage is rather simple: It contains the properties width, height, and nBits
of the image and methods used in the actual project. My methods are described in the
chapters devoted to projects. Here is the definition of our class CImage.
class CImage
{ public Byte[] Grid;
public int width, height, nBits;
3
© Vladimir Kovalevsky 2019
V. Kovalevsky, Modern Algorithms for Image Processing, https://doi.org/10.1007/978-1-4842-4237-7_1
Chapter 1 Introduction
public CImage(int nx, int ny, int nbits, byte[] img) // constructor
{
width = nx;
height = ny;
nBits = nbits;
Grid = new byte[width * height * (nBits / 8)];
for (int i = 0; i < width * height * nBits / 8; i++) Grid[i] = img[i];
}
} //*********************** end of class CImage *****************
4
CHAPTER 2
Noise Reduction
Digital images are often distorted by random errors usually referred to as noise. There
are two primary kinds of noise: Gaussian noise and impulse noise (see Figure 2-1).
Gaussian noise is statistical noise having a probability distribution similar to a Gaussian
distribution. It arises mainly during acquisition (e.g., in a sensor). It could be caused
by poor illumination or by high temperature of the sensor. It comes from many natural
sources, such as the thermal vibrations of atoms in conductors, referred to as thermal
noise. It influences all pixels of the image.
Impulse noise, also called salt-and-pepper noise, presents itself as sparsely occurring
light and dark pixels. It comes from pulse distortions like those coming from electrical
welding near the electronic device taking up the image or due to improper storage of old
photographs. It influences a small part of the set of pixels.
Figure 2-1. Examples of noise: (a) Gaussian noise; (b) impulse noise
5
© Vladimir Kovalevsky 2019
V. Kovalevsky, Modern Algorithms for Image Processing, https://doi.org/10.1007/978-1-4842-4237-7_2
Chapter 2 Noise Reduction
6
Chapter 2 Noise Reduction
Near the border of the image the window lies partially outside of the image. In this
case, the computation loses its natural symmetry because only pixels inside the image
can be averaged. A reasonable way to solve the border problem is to take control of the
coordinates (x + xx, y + yy) if they point out of the image. If these coordinates are out
of the image the summation of the gray values must be suspended and the divisor nS
should not be incremented.
An example of the algorithm for averaging the colors is presented here. We often use
in our code comments denoted by lines of certain symbols: lines marked with = label the
start and the end of a loop, lines with minus signs label if instructions, and so on. This
makes the structure of the code more visible.
The simplest slow version of the algorithm has four nested for loops.
This is source code: The reader can copy it and put into its C# source, and it will
work.
The parameter HalfWidth is half the width of the gliding window. The width and
height of the window are both equal to 2*HalfWidth+1. The variables x and y in the
preceding code are the indexes of pixels in Grid, and xx and yy are the indexes of the
pixels inside the gliding averaging window.
7
Chapter 2 Noise Reduction
The computation of sum in the innermost for loop needs W × W additions and
W × W accesses to the image for each pixel of the input image, which is quite time
consuming.
Let us remark once again that averaging filters, although they are very efficient
at reducing the intensity of Gaussian noise, strongly blur the image. Therefore they
should not be used for noise reduction. I suggest using the sigma filter described later
in this chapter for this purpose. Averaging is used for the purpose of shading correction
(see Chapter 4). Therefore it will be mostly used with a rather large gliding window, as
large as half the width of the image. Then the simplest averaging routine becomes so
time consuming that it is practically impossible to use it. For example, in the case of a
grayscale image of 1000 × 1000 pixels and a gliding window of 400 × 400 pixels, which is
typical for shading correction, the runtime of the function Averaging on a standard PC
can take about 20 minutes.
8
Chapter 2 Noise Reduction
actual row of the image (Figure 2-2). The filter then directly calculates the sum over the
window having its central pixel at the beginning of a row; that is, by adding up the sums
saved in the columns. Then the window moves one pixel along the row, and the filter
calculates the sum for the next location by adding the value of the column sum at the
right border of the window and by subtracting the value of the column sum at the left
border. It is necessary to check whether the column to be added or subtracted is inside
the image. If it is not, the corresponding addition or subtraction must be skipped.
Old
window
Old column
W×W
1×W - - - -
New
column
1×W New
window
- + W×W
Actual row
+ + + +
+Y
Due to applying a similar procedure for the calculation of the column sums, the
average number of additions or subtractions per pixel is reduced to ≈2 + 2 = 4. The
sum inside the window must be calculated directly (i.e., by the addition of HalfWidth + 1
sums of columns) only for a pixel at the beginning of each row. The sums of columns
must be calculated directly only for the pixels of the first row of the image.
The filter updates the values of the columns when proceeding to the next row of
the image by adding the gray value below the lower end and subtracting the gray value
at the upper end of each column (Figure 2-2). In this case it is also necessary to check
whether the gray value to be added or subtracted is in the image. The filter divides (with
rounding) the sum by the number of pixels in the intersection of the window with the
image as soon as the sum of the gray values in a window is calculated and saves the
result in the corresponding pixel of the output image.
9
Visit https://ebooknice.com to
discover a wide range of
eBooks across various genres.
Enjoy exclusive deals and
discounts to enhance your
reading experience. Start your
digital reading journey today!
Chapter 2 Noise Reduction
Here is the source code of the simplest version of the fast averaging filter designed for
filtering grayscale images.
10
Chapter 2 Noise Reduction
SumWind += SumColmn[x];
nPixWind += nPixColmn[x];
}
if (yout >= 0 && xsub >= 0)
{
SumWind -= SumColmn[xsub];
nPixWind -= nPixColmn[xsub];
}
if (xout >= 0 && yout >= 0)
Grid[xout + width * yout] = (byte)((SumWind + nPixWind / 2) /
nPixWind);
} //===================== end for (int x = 0; =====================
} //====================== end for (int y = 0; ======================
return 1;
} //************************* end FastAverageM ***********************
I present next the universal source code of the fast average filter designed both for
color and grayscale images. It uses the variable int nbyte, which is set to 3 for color and
to 1 for grayscale images. We define for the sum of color intensities in the gliding window
of (2*hWind + 1)2 pixels an array SumWind[3] of three elements for sums of red, green,
and blue intensities. In the case of a grayscale image, only the element SumWind[0] is
being used. We use the following variables as described next.
The location with the coordinates (c+nbyte*x, nbyte*y) is the location of a
color channel, one of red, green, or blue channels whose intensity is added to the
corresponding element of the array SumColmn. The location (c+nbyte*x, nbyte*ysub)
is that of a color channel whose intensity is to be subtracted from SumColmn. The
variable c+nbyte*x is the abscissa of the short column whose contents are to be added
to SumWind[c]. The variable c+nbyte*xsub is the abscissa of the short column whose
contents are to be subtracted from SumWind[c].
11
Chapter 2 Noise Reduction
12
Chapter 2 Noise Reduction
This source code can be used in a corresponding Windows Forms project. It is not
the fastest version; it can be made 50 percent faster by removing the multiplications from
the interior loop. Some multiplications can be performed before starting the loop; some
others can be replaced by additions. A still faster version can be made containing the
following nine loops instead of the two loops with the indexes y and x in FastAverageM
or in FastAverageUni:
Each of the nine loops processes a part of the image (see Figure 2-3) that is either
hWind + 1 pixels wide or hWind + 1 pixels high.
13
Chapter 2 Noise Reduction
hWind+1
hWind+1
Figure 2-3. The nine parts of the image corresponding to the nine loops
This version of the fast averaging filter can be used only if the condition hWind ≤
min (width, height)/2 - 1 is fulfilled. In such a version of the routine the interior loops
with the variable xOut contain no multiplications and no if instructions. The routine
is about 60 percent faster than the previously described FastAverageM. However, it
is much longer and much more difficult to debug. The gain in speed is not essential:
This code uses 0.7 seconds to process a big color image of 2448 × 3264 pixels with the
gliding window of 1200 × 1200 pixels, whereas FastAverageM takes 1.16 seconds. These
calculation times are almost independent from the size of the gliding window: They are
0.68 and 1.12 seconds correspondingly for the case of a gliding window of 5 × 5 pixels.
14
Chapter 2 Noise Reduction
-Y
+Y
Figure 2-4. Example of weights in the gliding window of the classical Gauss filter
These values are called the weights of the filter. The weights corresponding to the
two-dimensional Gauss law are floats less than one:
15
Chapter 2 Noise Reduction
additions per color channel of a pixel independent from the size of the window. We have
calculated that the standard of the equivalent Gaussian distribution is proportional to the
half-width of the gliding window of the averaging filter. In Table 2-1 hWind is the half-width
of the averaging window, and Sigma is the standard of a random variable whose distribution
corresponds to the weights calculated by the triple filtering with the fast filter.
hWind 1 2 3 4 5
You can see that the relation Sigma/hWind tends to 1 when the width of the window
increases.
Figure 2-5 shows how the weights of the approximate Gauss filter differ from true
Gauss weights.
17
Chapter 2 Noise Reduction
Figure 2-7. The same image after filtering with median of 5 × 5 pixels
Using the median for the suppression of impulse noise is also not recommended
because it will delete objects having the shape of thin lines that have nothing to do with
noise. I suggest an efficient method in a later chapter.
CHAPTER XVII.
GLADYS HEPBURN'S FIRST SUCCESSES.
The little ones from Glynde House have been here this
evening, and we all had a good game of play. It was rather
fun to feel that, as I had a printed book out, nobody would
count me too childish for my age, and so I could just enjoy
myself as much as ever I liked. Was that silly?
I wonder how soon poor Maggie will hear about her MS.
She seems getting rather impatient. I don't wonder, for I
have often felt dreadfully impatient.
First of all there came a long letter from Nellie, just like
her dear self all through.
But then came the best of all. A letter was waiting for
me at home,—from Mr. Willis. And he offers to give me £25
for the copyright of "Tom and Mary," which he thinks will
make a 5s. book. And if I agree, it is to go to the printer's
at once.
Oh, I am so glad and thankful! It does seem so kind of
God to answer prayer like this. I know quite well I didn't
half expect it.
CHAPTER XVIII.
SERIOUS NEWS.
But it did not. The Romillys were off first. So then Uncle
Tom sent another copy of the same telegram to the station
where we believed they would stop for lunch, and a second
copy to Beckdale Station, which is some miles off from
Beckdale House.
We are afraid now that they will not know what has
happened, till they get to Beckdale Station. If the first
telegram had reached them, we must have heard before
this.
CHAPTER XIX.
A MOUNTAIN STATION.
"It always seems that you must have had so much. But
I want to say one word. I think the girls will behave well,
and not give trouble;—still, if any difficulty should arise,
there is always Lady Denham. You could not do harm by
appealing to her. And pray write freely to Nellie. She never
makes mischief."
CHAPTER XX.
AND A YORKSHIRE DALE.
THE SAME—continued.
"Oh, it is splendid!"
The hills on this side of the Dale, behind our house, are
more smooth and round, and less lofty. Higher up the Dale,
some miles off, we have glimpses of mountains, which I am
told are over two thousand feet in height. Their summits are
swathed in cloud at present.
Elfie was awake all night, and to-day she is shaken and
hysterical, tears springing at the least word. I would not let
her come downstairs till after lunch. Now she is on the
drawing-room sofa, sound asleep, and I am journalising at a
side-table. I feel safe in so doing, for once. We have had
another wet morning; and the sun having come out since
lunch, our whole party started ten minutes ago for a
ramble. They will not be back for at least two hours, if rain
keeps off. So I may as well utilise the time.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebooknice.com