IN THE MATLAB ENVIRONMENT
M.Mudrova, A. Prochazka
Instituteof ChemicalTechnology, Department of Computingand ControlEngineering
Abstract
The paper is devoted to possibilities of geometric modications of images to
enable connection of separate scenes of overlaying images using their selected
features. ResultsofvariousimagetransformsveriedintheMatlabenvironment
are compared with standard software tools. Final algorithms are veried for
simulatedimagesat rst and thenappliedto realimages.
Keywords: ImageRegistration, Image Stitching,AlphaBlending, SpatialTransformations
1 Introduction
Image registration[5 , 7 ,6 ]is animportant partof imagerestoration that useobjective criteria
and priorknowledge to improvepictures. Thismethod processes distortedimages thepixelsof
which are shiftedfrom theircorrect position. Another pictureof the same object taken from a
dierent camerapositionoften servesasa controlimage. Thissituation isvery commonin the
remote sensing [2 ] where image registration method helps to nd the corresponding points in
two imagesofthesame regiontaken fromthedierent viewingangles. The paperdescribesthe
application ofimageregistration intheimagestitching.
(a) Original Images
(b) Stitched Image
Figure1: Processofimagestitchingpresenting(a)threeoverlappingoriginalimagesofSt. Vitus
cathedral,(b) thenalstitchedimageobtainedbytheCanon companysoftware
Manynewdigitalcameras includingtheirprofessionalsoftwareprovidethepossibilitiesof
stitching images- thatmeansjoiningthepartiallyoverlappingsnapsto create panoramas. But
- after takingsuitablephotos - it ispossibleto useanyother imageprocessingsoftware aswell
[3 ]. Various algorithms producingdesired picture from original photos can be implemented in
thesimilarway. Thegoalstudiedinthepaperisinstitchingof imagesbymeansoftheMatlab
system and its Image Processing Toolbox [1 ]. Three snaps of St. Vitus Cathedral in Prague
intheJPEGformatonlyso thattheminimumcompressionlevel waschosen.
2 Image Registration Principle
Thegoal ofimageregistrationisremovingofimagedistortionaccording tosome prior
informa-tion. Thepixelsintheincomingdistortedimageareshiftedfromtheircorrectpositioncausedby
variousreasons. Thefactof makingonlytheplanarprojectionsofthree dimensionalobjects or
variousviewer's positions belongs to themost common causesof distortion. Moreover, various
optical systemscan producevarioustypesof distortion. The spatialtransformationsconstitute
abasicmathematicaltoolformappingreceivingdistortedimageinto correctsystem. The prior
informationaboutproperpositionsofpixelsisoftengivenbyanother(base)pictureofthesame
scenetaken fromthedierentpointofview. Thecoordinatesysteminoneoftheimagesusually
is notCarthesian(see Fig.2). Even,the curvesdescribingthe systemneednotto be linear. It
is obvious that the shapes of the areas inside one image are quite dierent from the shapesof
thesame areas inthesecond one.
(a) (b)
Figure 2: An example of the image distortion caused by various points of view. (a) Image of
Carthesiangrid viewedfrom thedirection ofz-axis. (b)The same grid distortedwithselection
of anotherviewerposition
The resultof applicationof spatialtransformation to thedistortedimageI(x;y)is anew
imageJ(x ;y) whereeverypixel(x;y) isevaluatedbyselectedspatialtransformationequations:
x=F x (x;y) (1) y=F y (x;y) (2) Forms of functions F x ;F y
are given by the selected type of transformation. Projective,
aÆne,polynomial,linearconformalandothermethodsbelongtothereasonabletypesofspatial
transformations. The functions' parameters are estimated from the selected set of points for
whichweknowthepositioninthenewimage. Thisinformationistakenfromcomparisonofthe
baseimageinthecaseofimageregistration. Asthepixelcoordinatesx;yinthenewimageneed
notbe integer, theuse of an appropriateinterpolation method isnecessary to knowthe colour
levelexactly inthepixel coordinates. An exampleofimage registrationisshowninFig. 3.
(a) (b) (c) (d)
Figure3: Anexampleofimageregistrationpresenting(a)originalimageservingasaprototype
imageusedasthebaseimageintheregistrationprocess,(b)distortedimageexportedfrom 3D
drawing system in sililar way as the base image, (c) selection of control points in the Matlab
system, (d) resulting image after registration after the application of the aÆne transform and
Stitchingimages meansjoiningseveral partiallyoverlappedpicturesinto onepanorama. In the
digital photography there are some basic rules for taking incoming snaps described in [4 ] but
ingeneral itwouldbepossibleto joinanytwo(or more)corresponding picturesresultingfrom
various systems. The results of image stitching usually are not perfect, but dependingon the
usedalgorithmsandqualityofsourcepicturesthey canbegoodenoughto notnoticethejoins.
Two mainproblemsmustbe solved to accomplish thesatisfactoryresult:
Source imagesregistration bymeansofspatialtransformations
Mapping colourofsource imagesusinghistogram adjustment
The followingMatlab algorithm is focused on solvingthe rst problem epecially. Its function
wasveriedinjoiningoftwoupperphotosofSt. VitusCathedral(Fig.1a). Itcanbeappliedto
thegrayscale images orto theR,G,B colourlayers separately inthecaseof true-colourimages.
Figure 4: Selectionof control pointsset forthe given imageregistration. The important point
pairswere selected inbothimagesand corrected bymeansof correlation analysis
The algorithmconsistsof 4 steps:
1. Importinputimages into Matlab environment usingcommandimread
2. Registrationof the upperimage according to the lower one. The set of 42 control points
(Fig. 4) was selected using command cpselect for estimation of the parameters for
fol-lowingspatialtransform. Thesemanually selectedpointswerecorrectedusingcorrelation
analysis (cpcorrcommand). The projective transformand bicubic interpolationmethod
seems to be the most suitable modication in the case of these pictures. Result of its
applicationisshownintheFig.5. Themodiedpictureservesasaninputimageinto the
followingpartof thealgorithm
3. Selection of the cutting linein both images. The vertical line(at the similar position as
at theCanonpanorama) hasbeenselected intheupperimage. Thecorrespondinglinein
thelowimagewasfoundbymeansofcorrelationoflinescolorprole(Thesameresolution
must have beenensuredbypreviousresamplingofimages)
4. Joining selected parts of both images into one. The method of alpha blending has been
Figure5: Anexampleofanimagetransformpresenting(a)theupperoriginalimageofSt. Vitus
Cathedraland (b) thesame imagemodied withprojective transform
4 Results
Fig.6comparesresultsofrealimagesstitchingachievedbystandardCanonsoftwareand
result-ing from theMatlab algorithm described above. The cutting line has beenselected according
(a) (b) (c)
Figure6: Resultingimagesand theircriticaldetailspresenting(a)stitchingwithoutany
cutting lineselection - as picturesare joined inthe vertical direction,theline going througha
remarkablehorizontallinecan bemore applicable. Thisfactis documentedintheFig.7.
Figure 7: The real image od St. Vituscathedral and its critical detail stitched in the Matlab
environment at theselected horizontalprole
5 Conclusion and Suggestions for Further Investigation
It is possible to summarize that the Matlab system including its Image Processing Toolbox
provides large possibilitiesof spatial transformationsand image registration. Achieved results
documents wide possibilities of application of Matlab tools in the stitching process of given
images. The presented algorithm can be completed with a better solution of colour mapping.
Theappropriatealgorithmforautomaticndingthesamedetailsintheoverlappedpartsofthe
stitchedimages willbefurtherstudied aswell.
Acknowledgments
The work has beensupported bythe research grant of the Facultyof Chemical Engineeringof
[1] Humusoft,Praha. Matlab - Image Processing Toolbox - User'sManual, 2002.
[2] Hozman J. Klma M., Bernas M. and Dvorak P. Zpracovan obrazove informace.
CVUT,
FEL,Praha,1999.
[3] Berceanu M. StitchingPanoramas. www.berceanu.com.au, 2002.
[4] Ne O. Tajna kniha o digitaln fotograi. UnisPublishing,Brno, 2001.
[5] Bosdogianni P.Petrou M. Image Processing,TheFundamentals. JohnWileyandSons, UK,
1999.
[6] Benes B.SochorJ.,
ZaraJ. Algoritmy poctacove graky.
CVUT,FEL,Praha,1996.
[7] Marenka S. Watkins Ch., Sadun A. Modern Image Processing: Warping, Morphing and
Classical Techniques. Academic Press,UK, 1993.
M. Mudrova,A.Prochazka
Instituteof ChemicalTechnology,Prague
Department of Computingand ControlEngineering
Technicka1905, 166 28 Prague 6
Phone.: 00420-22435 4027, Fax: 00420-22435 5053
E-mail: [email protected], [email protected]