Table Of ContentSPRINGER BRIEFS IN COMPUTER SCIENCE
Borko Furht
Esad Akar · Whitney Angelica Andrews
Digital Image
Processing:
Practical
Approach
123
SpringerBriefs in Computer Science
SeriesEditors
StanZdonik,BrownUniversity,Providence,RhodeIsland,USA
ShashiShekhar,UniversityofMinnesota,Minneapolis,Minnesota,USA
XindongWu,UniversityofVermont,Burlington,Vermont,USA
LakhmiC.Jain,UniversityofSouthAustralia,Adelaide,SouthAustralia,Australia
DavidPadua,UniversityofIllinoisUrbana-Champaign,Urbana,Illinois,USA
XueminShermanShen,UniversityofWaterloo,Waterloo,Ontario,Canada
BorkoFurht,FloridaAtlanticUniversity,BocaRaton,Florida,USA
V.S.Subrahmanian,UniversityofMaryland,CollegePark,Maryland,USA
MartialHebert,CarnegieMellonUniversity,Pittsburgh,Pennsylvania,USA
KatsushiIkeuchi,UniversityofTokyo,Tokyo,Japan
BrunoSiciliano,UniversitàdiNapoliFedericoII,Napoli,Italy
SushilJajodia,GeorgeMasonUniversity,Fairfax,Virginia,USA
NewtonLee,NewtonLeeLaboratories,LLC,Burbank,California,USA
SpringerBriefs present concise summaries of cutting-edge research and practical
applications across a wide spectrum of fields. Featuring compact volumes of 50 to
125pages,theseriescoversarangeofcontentfromprofessionaltoacademic.
Typicaltopicsmightinclude:
(cid:129) Atimelyreportofstate-of-theartanalyticaltechniques
(cid:129) A bridge between new research results, as published in journal articles, and a
contextualliteraturereview
(cid:129) Asnapshotofahotoremergingtopic
(cid:129) Anin-depthcasestudyorclinicalexample
(cid:129) A presentation of core concepts that students must understand in order to make
independentcontributions
Briefs allow authors to present their ideas and readers to absorb them with
minimal time investment. Briefs will be published as part of Springer’s eBook
collection, with millions of users worldwide. In addition, Briefs will be available
forindividualprintandelectronicpurchase.Briefsarecharacterizedbyfast,global
electronic dissemination, standard publishing contracts, easy-to-use manuscript
preparation and formatting guidelines, and expedited production schedules. We
aim for publication 8-12 weeks after acceptance. Both solicited and unsolicited
manuscriptsareconsideredforpublicationinthisseries.
Moreinformationaboutthisseriesathttp://www.springer.com/series/10028
(cid:129)
Borko Furht Esad Akar
Whitney Angelica Andrews
Digital Image Processing:
Practical Approach
BorkoFurht EsadAkar
DepartmentofComputer&Electrical DepartmentofComputer&Electrical
EngineeringandComputerScience EngineeringandComputerScience
FloridaAtlanticUniversity FloridaAtlanticUniversity
BocaRaton,FL,USA BocaRaton,FL,USA
WhitneyAngelicaAndrews
DepartmentofComputer&Electrical
EngineeringandComputerScience
FloridaAtlanticUniversity
BocaRaton,FL,USA
ISSN2191-5768 ISSN2191-5776 (electronic)
SpringerBriefsinComputerScience
ISBN978-3-319-96633-5 ISBN978-3-319-96634-2 (eBook)
https://doi.org/10.1007/978-3-319-96634-2
LibraryofCongressControlNumber:2018952345
©TheAuthor(s),underexclusivelicencetoSpringerNatureSwitzerlandAG2018
Thisworkissubjecttocopyright.AllrightsarereservedbythePublisher,whetherthewholeorpartofthe
materialisconcerned,specificallytherightsoftranslation,reprinting,reuseofillustrations,recitation,
broadcasting,reproductiononmicrofilmsorinanyotherphysicalway,andtransmissionorinformation
storageandretrieval,electronicadaptation,computersoftware,orbysimilarordissimilarmethodology
nowknownorhereafterdeveloped.
Theuseofgeneraldescriptivenames,registerednames,trademarks,servicemarks,etc.inthispublication
doesnotimply,evenintheabsenceofaspecificstatement,thatsuchnamesareexemptfromtherelevant
protectivelawsandregulationsandthereforefreeforgeneraluse.
The publisher, the authors, and the editorsare safeto assume that the adviceand informationin this
bookarebelievedtobetrueandaccurateatthedateofpublication.Neitherthepublishernortheauthorsor
theeditorsgiveawarranty,expressorimplied,withrespecttothematerialcontainedhereinorforany
errorsoromissionsthatmayhavebeenmade.Thepublisherremainsneutralwithregardtojurisdictional
claimsinpublishedmapsandinstitutionalaffiliations.
ThisSpringerimprintispublishedbytheregisteredcompanySpringerNatureSwitzerlandAG
Theregisteredcompanyaddressis:Gewerbestrasse11,6330Cham,Switzerland
Preface
This book is intended for beginners in the field who would like to understand the
basic concepts of digital image processing and apply them in programming some
fundamentaldigitalimageprocessingalgorithms.Itisourassumptionthatthereader
hassomebackgroundinprogrammingincludingthebasicsofCandC++.Thebook
isofpracticalnature,andthefundamentalconceptsofimageprocessingdiscussedin
each chapter are showcased with demo programs. The reader is encouraged to
understand and run these programs as well as create similar programs proposed in
thebook.
Thebookconsistsoftenchapters.Thebookbeginswiththeintroductiontoimage
concept, classification of images, and various image formats. Then, it follows up
with Chaps. 2 and 3 on creating user interface and image loading and rendering.
Aftersuccessfullycompleting andunderstandingtheseconcepts,thereaderwillbe
able to begin writing basic programs in image processing. In Chaps. 4 and 5, we
introduce some relatively simple image processing techniques, such as creating
imagehistogramsanddetectingchangesincolorsandpresentprogramsthataccom-
plishthesetechniques.Chapters6and7introducemorecompleximageprocessing
problems and their solutions including lossless image compression and similarity-
basedimageretrieval.
When completing these chapters and related programming examples, the reader
will be able to understand and write some exciting image processing applications.
Lastly,Chaps.8,9,and10presentthreeapplicationsincludinghowtohidedatain
digital images, how to create a transition from one to another image, and how to
embed one image into another image with resizing. Chapters 11, 12, and 13 were
completedbystudentsaspartofIntroductiontoImageandVideoProcessingclassat
FloridaAtlanticUniversitytaughtinSpring2018.
v
vi Preface
The book can be used as a practical textbook for basic courses on image
processing.Themainfeaturesofthebookcanbesummarizedasfollows:
1. Thebookdescribesthebasicconceptofdigitalimageprocessing.
2. Thefocusofthebookispracticalprogrammingexamplesoffundamentalimage
processingalgorithms.
3. Link to complete programs allows readers to run, test programs, and design
various image processing solutions. The libraries used in this book can be
found at https://github.com/scarface382/libraries, and source code for all pro-
grams described in the book can be found at http://github.com/scarface382/
multimedia-examples.
BocaRaton,FL,USA BorkoFurht
2018 EsadAkar
WhitneyAngelicaAndrews
Contents
1 IntroductiontoDigitalImaging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 ImageConcept. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 ImageFileFormats. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 ImageResolution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 CreatingUserInterface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1 CompilingtheProgram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 ImageLoadingandRendering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.1 LoadingImagefromDisk. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 WritingtoDisk. .. . . . . . .. . . . . .. . . . . .. . . . . . .. . . . . .. . . . 15
3.3 CreatingTexturefromImages. . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.4 ConvertingColortoGrayscaleImages. . . . . . . . . . . . . . . . . . . . . 17
4 CreatingImageHistograms. . .. . . .. . . .. . . . .. . . .. . . . .. . . .. . . 21
4.1 ProgramforCreatingHistograms. . . . . . . . . . . . . . . . . . . . . . . . . 22
5 DetectingChangesinColor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6 LosslessJPEGImageCompression. . . . . . . . . . . . . . . . . . . . . . . . . . 35
6.1 ExampleofaHuffmancoder. . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.2 HuffmanProgrammingExample. . . . . . . . . . . . . . . . . . . . . . . . . 40
6.3 LosslessJPEGExamples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
7 Similarity-BasedImageRetrieval. . . . . . . . . . . . . . . . . . . . . . . . . . . 51
8 DataHidinginDigitalImages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
9 ImageTransition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
9.1 CompilerOptimizations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
10 Image-to-ImageEmbedding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
11 ChangingColorofSelectedObjects. . . . . . . . . . . . . . . . . . . . . . . . . 77
11.1 ImplementationDescription. . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
vii
viii Contents
12 LoadingandInsertingObjectsinanImage. . . . . . . .. . . . . . . . . . . . 81
13 SwapFacesinanImage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.1 RapidObjectDetectionUsingaBoostedCascadeofSimple
Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.2 FeaturesinImages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.3 IntegralImage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Chapter 1
Introduction to Digital Imaging
1.1 Image Concept
Imageisatwo-dimensionalarrayofsamplesorpixels,asillustratedinFig.1.1.
Each pixel consists of number of bits. Based on number of bits per pixel,
Table 1.1 classifies images into four categories: binary, computer graphics, gray-
scale, and color images. Digital images come in different flavors. Images can be
made up pixels that are either fully black or fully white, called binary images.
Grayscale images contains pixels where the pixel color values vary between a
range of black, grey, and white. Color images can capture pixel values of any
colorsuchasred,blue,andgreen.
In this book, we will focus on color and grayscale images. The most common
representationofcolorimages,RGBrepresentation(Red,Green,Blue)isbasedon
trichromatic theory that the sensation of color is produced by selectively exciting
three classes of receptors in the eye. Figure 1.2 shows the three-dimensional
representationofcolorimagesconsistingofthesethreecomponents:R,G,andB.
In 24-bit color format, each color is represented with 8 bits. Therefore, the
elements in the three-dimensional cube have values from (0,0,0) to (255,255,255).
Black color isdefinedas(0,0,0) andthewhite component as(255,255,255). Gray-
scale image is defined as the straight line in the three-dimensional cube, which is
whenR¼G¼B.
The term channel in the context of digital images refers to number of color
components used to display a pixel value. A three-channel image simply means a
RGBcolorimage.Pixelsofgrayscaleimagescanberepresentedwithasinglevalue
sotheyaresinglechannelimages.RGBAimageswhichstandforRed,Green,Blue,
AlphaareregularRGBimageswithafourthchannelcalledthealphachannelwhich
controlsthetransparencylevelofthepixels.Inmostdigitalimageeditingsoftware,
layers of image objects can be stacked together. By tweaking the transparency/
opacity levels of these layers, the bottom layer can be made to show through as
seeninFig.1.3.Ofcourse,whenthefinaldesignisexportedasaregularimagefile,
©TheAuthor(s),underexclusivelicencetoSpringerNatureSwitzerlandAG2018 1
B.Furhtetal.,DigitalImageProcessing:PracticalApproach,SpringerBriefsin
ComputerScience,https://doi.org/10.1007/978-3-319-96634-2_1