Professional Documents
Culture Documents
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
MATLABandOctaveFunctions
forComputerVisionandImage
Processing
PeterKovesi
CentreforExplorationTargeting
SchoolofEarthandEnvironment
TheUniversityofWestern
Australia
ThissitewasdevelopedwhileIwaswiththe
SchoolofComputerScience&
SoftwareEngineering
TheUniversityofWestern
Australia
IcontinuetocollaboratewiththeschoolandI
thankthemforcontinuingtohostthissite.
IndextoCodeSections
FeatureDetectionvia
PhaseCongruency
SpatialFeatureDetection
IntegralImages
Non-MaximaSuppression
andHysteresis
Thresholding
EdgeLinkingandLine
SegmentFitting
TestGratingforEdge
1 of 17
Thecompletesetofthese
functionsisavailableasazipfile
MatlabFns.zip
Howtocitethissite
MITLicense
NotesonusingOctavealmostallofthesefunctions
rununderOctave.Withthe
releaseofOctave3you
haveaveryviable
alternativetoMATLAB.
11/13/2010 09:08 AM
Detection
ImageDenoising
SurfaceNormalsto
Surfaces
ScalogramCalculation
Anisotropicdiffusion
GreyScale
Transformationand
Enhancement
FrequencyDomain
Transformations
FunctionsSupporting
ProjectiveGeometry
FeatureMatching
ModelFittingandRobust
Estimation
FingerprintEnhancement
InterestingSynthetic
Images
ASCIIImageGeneration
RotationTransforms
ImageDisplay,Image
WritingandMiscellaneous
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
Can'tfindwhatyouwant
here?Havealookat
Otherhighly
recommendedComputer
Visionsoftwaresites
MATLAB/Octavecompatibilityof
individualfunctionisindicatedas
follows
RunsunderMATLABand
Octave.
OnlyrunsunderMATLAB.
NottestedunderOctave
(yet).
Ireceivesomanymailmessages
regardingthissitethatIhave
difficultyrespondingtothemall.I
willendeavortorespondtomail
thatdirectlyconcernstheuseof
individualfunctions.However,
pleasenoteIdonothavethetime
toprovideanon-linevision
problemsolvingservice!
Pleasereportanybugsand/or
suggestenhancementsto
Cheers,
PeterKovesi
FeatureDetectionviaPhaseCongruency
Phasecongruencyisanilluminationandcontrastinvariantmeasureof
2 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
featuresignificance.Unlikegradientbasedfeaturedetectors,whichcan
onlydetectstepfeatures,phasecongruencycorrectlydetectsfeaturesat
allkindofphaseangle,andnotjuststepfeatureshavingaphaseangleof
0or180degrees.
phasecongmono.mThisfunctioncomputesphasecongruencyvia
monogenicfilters.Ithasexcellentspeedandmuchreducedmemory
requirementscomparedtotheotherphasecongruencyfunctionsbelow.
Howeveryoumayprefertheoutputfromphasecong3'sorientedfilters.
phasecong3.mThisfunctionsupersedesphasecong2.mandphasecong.m
beingfasterandrequiringlessmemory.
Deprecated:phasecong.mOriginalcodeforcalculatingphase
congruencyinanimage.Thisfunctionalsoreturnsafeaturetype
image.Notethisfunctionissupersededbyphasecong2.mand
phasecong3.mandisonlyhereforreference.
Deprecated:phasecong2.mPhasecongruencycodethatcombines
edgeandcornerdetection,andprovidesbetterlocalization.Note
thisfunctionissupersededbyphasecong3.mand
phasecongmono.mandisonlyhereforreference.
dispfeat.mThisfunctionprovidesvisualisationandstatisticsofthedifferent
featuretypesfoundinanimagebyphasecong.Typicallyyouwillfinda
broaddistributionofallfeaturetypesbetweenstepedgesandlines.This
functionneedsedgelink.m(seebelow).
odot.mDemonstratestheactionsofthe'Odot'and'Oslash'operatorsona
1Dsignal.Theseoperatorsallowonetodecomposeandcombinesignals
inawaythatisconsistentwiththeLocalEnergymodeloffeature
perception.
spatialgabor.mappliesasingleorientedGaborfiltertoanimage.
phasesymmetry
image
phasesym.mCodeforcalculatingphasesymmetry.Thiscanbeusedasa
lineandblobdetector.Phasesymmetryisanilluminationandcontrast
invariantmeasureofsymmetryinanimage.(Abrightcircleisnotmore
'symmetric'thanagreycircleascanbethecasewithsomeother
3 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
measures!).(UpdatedMay2009)
phasesymmono.mThisfunctioncomputesphasesymmetryviamonogenic
filters.Hasexcellentspeedandmuchreducedmemoryrequirements
comparedtophasesym.mHoweveryoumayprefertheoutputfrom
phasesym'sorientedfilters.
gaborconvolve.mCodeforconvolvinganimagewithabankoflog-Gabor
filters.Apre-processingstepfortextureanalysis,featuredetectionand
classification,etc.
plotgaborfilters.mAfunctionforplottinglog-Gaborfilters.Thisfunctionis
usefulforseeingwhateffectthevariousparametersettingshaveonthe
formationofalog-Gaborfilterbankusedinthefunctionsabove.
monofilt.mAnimplementationofFelsberg'smonogenicfilters.This
functionappliesabankofmonogenicfilterstoanimagetoobtainthe2D
analyticsignaloveranumberofscales.Asingaborconvolvethiscanbe
usedasapre-processingstepfortextureanalysis,featuredetectionand
classification,etc.
Anexplanationoftheimplementationofconvolutionwithlog-Gaborfilters
usedinthefunctionsabove.
References:
PeterKovesi,"SymmetryandAsymmetryFromLocalPhase".AI'97,
TenthAustralianJointConferenceonArtificialIntelligence.2-4December
1997.Proceedings-PosterPapers.pp185-190.
PeterKovesi,"ImageFeaturesFromPhaseCongruency".Videre:A
JournalofComputerVisionResearch.MITPress.Volume1,Number3,
Summer1999.
PeterKovesi,"EdgesAreNotJustSteps".ProceedingsofACCV2002
TheFifthAsianConferenceonComputerVision,MelbourneJan22-25,
2002.pp822-827.
PeterKovesi,"PhaseCongruencyDetectsCornersandEdges".The
AustralianPatternRecognitionSocietyConference:DICTA2003.
December2003.Sydney.pp309-318.
SpatialFeatureDetection
canny.mCannyedgedetector.
harris.mHarriscornerdetector.
fastradial.mAnimplementationofLoyandZelinski'sfastradialfeature
detector.
gaussfilt.mWrapperfunctionforconvenientGaussianfiltering.
derivative5.mcomputes1stand2ndderivativesofanimageusingthe
4 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
5-tapcoefficientsgivenbyFaridandSimoncelli.Usethisfunctioninsteadof
MATLAB'sGRADIENTfunctionformuchmoreaccurateresults.
derivative7.mcomputesderivativesusingthe7-tapcoefficientsgivenby
FaridandSimoncelli.
Reference:
ScannedimagesofmyphotocopyofHarrisandStephens'paper'A
CombinedCornerandEdgeDetector'.
IntegralImages
integralimage.mcomputesintegralimageofanimage.
integralfilter.mperformsfilteringusinganintegralimage.
intfilttranspose.mtransposesanintegralimagefilterspecification.
integaverage.mperformsaveragingfilteringusinganintegralimage.
Computationcostisindependentofaveragingfiltersize.
integgaussfilt.mThisfunctionapproximatesGaussianfilteringby
repeatedlyapplyingintegaverag.m.Thisallowssmoothingataverylow
computationalcostthatisindependentoftheGaussiansize.
solveinteg.mThisfunctionisusedbyinteggausfilt.mtosolveforthe
multipleaveragingfilterwidthsneededtoapproximateaGaussianof
desiredstandarddeviation.
Reference:
TechreportdescribinghighspeedapproximateGaussianfilteringvia
integralimages.
Non-MaximaSuppressionandHysteresisThresholding
nonmaxsup.mCodeforperformingnon-maximasuppressionforedge
images.
nonmaxsuppts.mCodeforperformingnon-maximasuppressionand
5 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
thresholdingofpointsgeneratedbyafeature/cornerdetector.Itoptionally
returnssub-pixelfeaturelocations.
hysthresh.mcodeforperforminghysteresisthresholding.
smoothorient.mappliessmoothingtoanorientationfieldwhichcanbe
usefulbeforeapplyingnonmaximalsuppression.
adaptivethresh.manimplementationofWellner'sadaptivethresholding
method.
EdgeLinkingandLineSegmentFitting
image
edges
labelededges
fittedlinesegments
edgelink.medgelinkingfunctionthatformslistsofconnectededgepoints
fromabinaryedgeimage.(Needsfindendsjunctionsandcleanedgelist
below).
drawedgelist.mplotsoutasetofedgelistsgeneratedbyedgelinkor
lineseg.
edgelist2image.mtransfersedgelistdatabackintoa2Dimagearray.
lineseg.mformsstraightlinesegmentsfittedwithaspecifiedtoleranceto
thelistsofconnectededgepoints.
maxlinedev.misalsousedbylineseg.mtocalculatedeviationsoftheedge
listsfromthefittedsegments.
findendsjunctions.mfindslinejunctionsandendingsinaline/edgeimage.
cleanedgelist.mcleansupasetofedgelistsgeneratedbyedgelinkor
linesegsothatisolatededgesandspursthatareshorterthanaminimum
lengthareremoved.
Exampleofusingthesefunctionsabove.
TestGratingforEdgeDetection
6 of 17
11/13/2010 09:08 AM
Testimage
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
Cannyedgeimage Phasecongruency
Colourcodedforfeature
type
step2line.mGeneratesatestimagewherethefeaturetypechangesfrom
astepedgetoalinefeaturefromtoptobottom,whileretainingperfect
phasecongruency.Thistestimageindicatestheimportanceofphase
congruencyirrespectiveoftheangleatwhichcongruencyoccursatand,
uptoapoint,irrespectiveoftherateatwhichtheamplitudespectrum
decayswithfrequency.Agradientbasededgedetectorproducesadouble
responseforallfeaturesthathavecongruenceofphaseatanglesother
thanzero(towardsthebottomofthetestimage).Thephasecongruency
detectormarksfeatureswithasingleresponse.Thecolourcodedimage
wasgeneratedbydispfeat.m
ImageDenoising
noisecomp.mCodefordenoisingimages.Thiscodediffersfromstandard
waveletdenoisingtechniquesinthatitusesnon-orthogonalwavelets,and
unlikeexistingtechniques,ensuresthatphaseinformationispreservedin
theimage.Phaseinformationisofcrucialimportancetohumanvisual
perception.Also,thiscodedoeshaveaneffectivewayofdetermining
thresholdlevelsautomatically.
Seetheexamplebelow,undergreyscaletransformationand
enhancement,foranexampleoftheuseofthisfunction.
Reference:
7 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
PeterKovesi,"PhasePreservingDenoisingofImages".TheAustralian
PatternRecognitionSocietyConference:DICTA'99.December1999.
PerthWA.pp212-217.
SurfaceNormalstoSurfaces
SurfaceNormals
SurfaceReconstruction
shapeletsurf.mFunctionreconstructsanestimateofasurfacefromits
surfacenormalsbycorrelatingthesurfacenormalswiththatthoseofa
bankofshapeletbasisfunctions.Thecorrelationresultsaresummedto
producethereconstruction.Thesumationofshapeletbasisfunctions
resultsinanimplicitintegrationofthesurfacewhileenforcingsurface
continuity.
Notethatthereconstructionisonlyvaliduptoascalefactor(whichcanbe
correctedfor).Howeverthereconstructionprocessisveryrobusttonoise
andtomissingdatavalues.Reconstructions(uptopositive/negativeshape
ambiguity)arepossiblewherethereisanambiguityofpiintiltvalues.Low
qualityreconstructionsarealsopossiblewithjustslant,orjusttiltdata
alone.However,ifyouhavefullgradientinformationyouarebetteroffwith
theFrankotChellappaalgorithmbelow.
frankotchellappa.mAnimplementationofFrankotandChellappa's
algorithmforconstructinganintegrablesurfacefromgradientinformation.
Ifyouhavefullgradientinformationinxandythisisprobablythebest
algorithmtouse.Itisverysimple,veryfastandhighlyrobusttonoise.If
youhavesurfacenormalinformationintheformofslantandtilt,andyou
haveanambiguityofpiinyourtiltdata,oronlyhaveslant,thentryusing
shapeltsurf.mabove.
grad2slanttilt.mConvertsgradientvaluesoverasurfacetoslantandtilt
angles.
slanttilt2grad.mConvertsslantandtiltanglesoverasurfacetogradients.
needleplotgrad.mGeneratesaneedleplotgivensurfacegradientsovera
surface.
needleplotst.mGeneratesaneedleplotgivenslantandtiltvaluesovera
surface.
8 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
testp.mGeneratesasynthetictestsurfacealongwithitssurfacenormals
fortestingshapeletsurf.
Reference:
PeterKovesi,"ShapeletsCorrelatedwithSurfaceNormalsProduce
Surfaces".10thIEEEInternationalConferenceonComputerVision.
Beijing.pp994-1001.2005
PowerPointSlides
Anexampleofhowmuch3Dshapeyoucangetfromveryminimal
surfacenormalinformation.
ScalogramCalculation
scalogram.mFunctiontocalculatethephaseandamplitudescalogramsof
a1Dsignal.TheanalysisisdoneusingquadraturepairsoflogGabor
wavelets.
Anisotropicdiffusion
anisodiff.mFunctiontoperformanisotropicdiffusionofanimagefollowing
PeronaandMalik'salgorithm.Thisprocesssmoothesregionswhile
preserving,andenhancing,thecontrastatsharpintensitygradients.
GreyScaleTransformationandEnhancement
extractfields.mseparatesfieldsfromavideoframe,andoptionally
9 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
interpolatesintermediatelines.
interpfields.minterpolateslinesonafieldextractedfromavideoframe.
normalise.mrescalesimagevaluesto0-1.
adjcontrast.madjustsimagecontrastusingsigmoidfunction.
adjgamma.madjustsimagegamma.
greytrans.mallowsyoutointeractivelyremapintensityvaluesinacolour
orgreyscaleimageviaamappingfunctiondefinedbyaseriesofspline
points.Afeebleattemptatreplicatingxv'sintensitymappingtool.Itisnotas
fastbutitdoesoperateonfloatingpointimagesallowingyoutobetter
preserveimagefidelity.(Needsremapim.m).
remapim.misanon-interactiveversionofgreytransthatallowsyouto
applyanintensitymappingtoacolourorgreyscaleimageusingamapping
functiondeterminedexperimentallywithgreytrans.Usefulifyouwantto
applythesamemappingfunctiontoasequenceofimages.
histtruncate.mtruncatesendsofanimagehistogram.Usefulfor
enhancingimageswithoutlyingvalues.
Exampleofusingsomeofthesefunctionsabovetoenhanceavideo
image.Howeveryoushouldnotethatmanysurveillancesystemsareclose
tobeinglegallyblind.
SeeVideoSurveillance:LegallyBlind?DICTA2009Melbourne.
FrequencyDomainTransformations
lowpassfilter.mconstructslow-passButterworthfilter.
highpassfilter.mconstructshigh-passButterworthfilter.
highboostfilter.mconstructshigh-boostButterworthfilter.
bandpassfilter.mconstructsband-passButterworthfilter.
homomorphic.mperformshomomorphicfilteringonanimage.Oneofmy
favouriteimageenhancementtechniques.(needshisttruncate.mand
normalise.m)
psf.mgeneratesavarietyofpoint-spreadfunctions.Thisfunctioncanbe
usefulwhenmanuallyspecifyingpoint-spreadfunctionsforWienerfiltering
orwithdeconvolutionfunctionssuchastheRichardson-Lucyalgorithm
(seetheMATLABimagetoolboxfunctiondeconvlucy.m).
psf2.misidenticaltopsf,itjusthasadifferentwayofspecifyingthe
functionshapewhichmaybemoreconvenientforsomeapplications.
imspect.mplotsimageamplitudespectrumaveragedoverallorientations.
freqcomp.mdemonstratesimagereconstructionfromitsFourier
components.
10 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
FunctionsSupportingProjectiveGeometry
imageofbeach
rectifiedbeach
homography1d.mcomputesthe2x21Dhomographyof3ormorepoints
alongaline.
homography2d.mcomputesthe3x32Dhomographyof4ormorepoints
inaplane.Thiscodefollowsthenormaliseddirectlineartransformation
algorithmgivenbyHartleyandZisserman.
fundmatrix.mcomputesthefundamentalmatrixfrom8ormorematching
pointsinastereopairofimagesusingthenormalised8pointalgorithm.
affinefundmatrix.mcomputestheaffinefundamentalmatrixfrom4or
morematchingpointsinastereopairofimages.
fundfromcameras.mcomputesfundamentalmatrixgiventwocamera
projectionmatrices.
normalise2dpts.mtranslatesandnormalisesasetof2Dhomogeneous
pointssothattheircentroidisattheoriginandtheirmeandistancefrom
theoriginissqrt(2).Thisisusedtoimprovetheconditioningofany
equationsusedtosolvehomographies,fundamentalmatricesetc.
hnormalise.mnormalisesanarrayofhomogeneouscoordinatessothat
theirscaleparameteris1.Pointsatinfinityareunchanged.
makehomogeneous.mconvertsanNxnptsarrayofinhomogeneous
pointstohomogeneouspointswithscale1.
makeinhomogeneous.mnormalisesanNxnptsarrayofhomogeneous
pointstoascaleof1andreturnstheinhomogeneouscoordinates.
imTrans.mappliesahomogeneoustransformtoanimage.Theoutput
imageoriginandsizeisadjustedtocontainthetransformedimage.(NoteI
wrotethiscodebeforeversion3oftheImageProcessingtoolboxwas
releasedwiththefunctionIMTRANSFORM.Youareprobablybetteroff
usingMATLAB'sIMTRANSFORM)
imTransD.mappliesahomogeneoustransformtoanimage.Noorigin
shiftisappliedtothetransformedimage.Iusethisfunctionforregistering
imagesetc.
digiplane.mallowsyoutodigitiseandtransformpointswithinaplanar
regioninanimage.
equalAngleConstraint.mAffinetransformconstraintsgiventwoequal
11 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
angles.
knownAngleConstraint.mAffinetransformconstraintsgivenaknown
angle.
lengthRatioConstraintAffinetransformconstraintsgivenalengthratio.
circleintersect.mFindsintersectionoftwocircles.Usethisfunctionto
solveforaffinetransformationconstraints.
circle.mDrawsacircle.
hcross.mHomogeneouscrossproduct,resultnormalisedtos=1.
hline.mPlot2Dlinesdefinedinhomogeneouscoordinates.
homoTrans2Dhomogeneoustransformationofpoints/lines.
plotPoint.mPlotspointwithspecifiedmarkandoptionaltextlabel.
IfyouareusingthesefunctionsaboveyoushouldlookatAndrew
Zisserman'sMATLABFunctionsforMultipleViewGeometry
Also,youmustlistentoTheFundamentalMatrixSongbyDanielWedge.
FeatureMatching
matchbycorrelation.mgeneratesputativematchesbetweenpreviously
detectedfeaturepointsintwoimagesbylookingforpointsthatare
maximallycorrelatedwitheachotherwithinwindowssurroundingeach
point.Onlypointsthatcorrelatemoststronglywitheachotherinboth
2
directionsarereturned.Thisisasimple-mindedN comparison.
matchbymonogenicphase.missimilartomatchbycorrelation,butinstead
matchesonorientedphasevaluesratherthangreyscalevalues.This
matcherperformsratherwellrelativetonormalisedgreyscalecorrelation.
Typicallytherearemoreputativematchesfoundandfeweroutliers.There
isagreatercomputationalcostinthepre-filteringstagebutpotentiallythe
matchingstageismuchfasteraseachpixeliseffectivelyencodedwithonly
3bits.(Thoughthispotentialspeedisnotrealizedinthisimplementation).
Seetestfundbelowtoseeanexampleoftheuseofthisfunction.
ModelFittingandRobustEstimation
Putativematchesobtained
12 of 17
Inlyingmatchesconsistent
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
bymatchbycorrelation.m
withfundamentalmatrix
ransac.mageneralpurposeimplementationoftheRANSACalgorithm.
ransacfithomography.mrobustlyfitsahomographytoasetofputatively
matchedimagepoints.
ransacfitfundmatrix.mrobustlyfitsafundamentalmatrixtoasetof
putativelymatchedimagepoints.Thisfunctionusesan8pointfundamental
matrixsolution.
ransacfitfundmatrix7.mrobustlyfitsafundamentalmatrixtoasetof
putativelymatchedimagepoints.ThisfunctionrequiresAndrew
Zisserman's7pointfundamentalmatrixcodeavailablefrom:MATLAB
FunctionsforMultipleViewGeometry
ransacfitaffinefund.mrobustlyfitsanaffinefundamentalmatrixtoasetof
putativelymatchedimagepoints.
ransacfitplane.mrobustlyfitsaplaneto3Ddatapoints.
ransacfitline.mrobustlyfitsalineto3Ddatapoints.
iscolinear.mtestsif3pointsarecolinear,usedbyransacfitplaneand
ransacfithomography.
fitline.mleastsquaresfitofalineto2Ddatapoints.
fitline3d.mleastsquaresfitofalineto3Ddatapoints.ContributedbyFelix
Duvallet.
fitplane.mleastsquaresfitofaplaneto3Ddatapoints.
testfitplaneexampleofusingransacfitplane.m
testfitlineexampleofusingransacfitline.m
testfundexampleofusingransacfitfundmatrix.m
testhomogexampleofusingransacfithoography.m
randomsampleabasicreplacementforrandsampletobeusedwith
ransac.mshouldyounothavethestatisticstoolbox,orareusingOctave.
Exampleofusingthesefunctionsabovetofindthefundamentalmatrix.
FingerprintEnhancement
ridgesegment.midentifiesridge-likeregionsofafingerprintimage.Italso
normalisestheintensityvaluesoftheimage.
13 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
ridgeorient.mestimatesthelocalorientationofridgesinafingerprint.
plotridgeorient.mplotsridgeorientationscalculatedbyridgeorient.
ridgefreq.mestimatesthelocalridgefrequencyacrossafingerprintimage.
freqest.mestimatestheridgefrequencywithinasmallblockofanimage.
Thisisusedbyridgefreq.
ridgefilter.menhancesafingerprintimageusingorientedfilters.
Exampleofusingthesefunctionsabove.
InterestingSyntheticImages
noiseonf.mgeneratesnoiseimageswithspecifiedamplitudespectra.One
cancreatepleasingcloudpatternimagesthisway.
cloud9.mcreatesamoviesequenceofnoiseimageswithspecified
amplitudespectra.Veryrelaxing.
derespolar.mGeneratesderesolvedimagesinpolarcoordinates.
polartrans.mGeneratesapolartransformationofanimage.Alinearor
logarithmicradiustransformationcanbespecified.
circsine.mGeneratesatestimageconsistingofacircularsinewave
grating.
ASCIIImageGeneration
14 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
matscii.mFunctiontogenerateASCIIimagesfromgreyscaleimages.A
bitretrobutmayhaveapplicationsforinterestingtextmessagesonyour
mobilephone!
HomogeneousTransforms
plotframe.mplotsacoordinateframespecifiedbyahomogeneous
transform.
trans.mhomogeneoustranlationmatrix.
rotx.mhomogeneousmatrixforrotationaboutx-axis.
roty.mhomogeneousmatrixforrotationabouty-axis.
rotz.mhomogeneousmatrixforrotationaboutz-axis.
homotrans.mhomogeneoustransformationofpoints/lines
invht.moptimizedinverseofhomogeneoustransformationmatrix
inveuler.msolvesforeuleranglesgivenahomogeneoustransform.
invrpy.msolvesforroll,pitch,yawanglesgivenahomogeneous
transform.
dhtrans.mcalculatesthe4x4homogeneousDenavitHartenbergmatrix
givenlinkparametersofjointangle,length,jointoffset,andtwist.
Quaternions
newquaternion.mconstructquaternionfromspecifiedangleandaxis.
matrix2quaternion.mconverts4x4homogeneousrotationmatrixto
quaternion
quaternion2matrix.mconvertsquaterniontoa4x4homogeneous
transformationmatrix.
quaternionrotate.musesquaterniontorotatevectors.
quaternionproduct.mcomputesquaternionproduct.
quaternionconjugate.mcomputesquaternionconjugate.
vector2quaternion.membedsa3-vectorinaquaternion.
Angle-AxisDescriptors
newangleaxis.mconstructsangle-axisdescriptorfromspecifiedangleand
15 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
axis.
matrix2angleaxis.mconvertshomogeneousrotationmatrixtoangle-axis
description
angleaxis2matrix.mconvertsangle-axisdescriptorto4x4homogeneous
transformationmatrix.
angleaxisrotate.musesangleaxisdescriptortorotatevectors
normaliseangleaxis.mnormalisesangle-axisdescriptorsothattheangle
hasamaximummagnitudeofpi.
ImageDisplay,ImageWritingandMiscellaneous
findimage.mDisplaysafiledialogboxtoallowyoutofindandloadyour
imageinteractively.Usefulwhenyouhaveforgottenthenameofyour
image,orcan'tbebotheredtypingitout.
show.mThisfunctiondisplaysanimage,automaticallysettingthecolour
maptogreyifitisa2Dimage,orleavingitascolourotherwise,andsetting
theaxestobe'equal'.Theimageisalsodisplayedas'TrueSize',thatis,
pixelsonthescreenmatchpixelsintheimage.Finallyatitlecorresponding
totheimagevariablenameisadded.
showfft.mdisplaystheamplitudespectrumofanfft.
showlogfft.mdisplaysthelogamplitudespectrumofanfft.
showsurf.mThisfunctionwrapsupthecommandsIusuallyusetodisplay
asurface.ThesurfaceisdisplayedusingSURFLwithinterpolatedshading,
inmyfavouritecolormapof'copper',withrotate3don,andaxisvis3dset.
togglefigs.mprovidesaconvenientmeansoftogglingthedisplayof
multiplefigures.Handyforcomparingimagesandplots.
imwritesc.mThisfunctioncombinesimagerescalingandwritingintothe
onefunction.Iftheimagetypeisdoubleimagevaluesarerescaledto
therange0-1sothatnooverflowoccurswhenwriting8-bitintensity
values.TheimageformattouseisdeterminedbyMATLABfromthefile
ending.Iftheimagetypeisofuint8norescalingisperformed.
matprint.mThisfunctionprintsoutamatrixusingaspecifiedCstyleformat
string.OftenyoufindthatMATLAB'sdefaultnumberformatsarenotwhat
youwant...
digipts.mFunctiontodigitisepointsinanimage.Thisfunctionusesthe
cross-haircursorprovidedbyGINPUT.Ifindthisismuchmoreuseable
thanthecursorusedbyIMPIXEL.Inadditioneachlocationdigitisedis
markedwithared'+'.
impadPadstheboundaryofanimagewithzeros.
imtrimTrimstheboundaryofanimage(unpadsit)
imsetborderSetsborderpixelsofanimagetoaspecifiedvalue.
16 of 17
11/13/2010 09:08 AM
http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/
removenanReplacesNaNvaluesinamatrixwithaspecifieddefaultvalue.
UsefulwhenyouwanttopreventNaNsfromcontaminatinganddestroying
someoperationonanarray,forexample,anFFT.
fillnanReplacesNaNvaluesinamatrixwiththevalueintheclosest
non-Nanpixel.
implace.mFunctiontoplaceanimageataspecifiedlocationwithina
largerimage.
superquad.mgeneratesparametricsurfacesofsuperquadratics.
supertorus.mgeneratesparametricsurfacesofasupertorus.
cubicroots.mcomputestherealrootsofacubic.
rgb2nrgb.mRGBtonormalisedRGBcolourconversion.
rgb2lab.mRGBtoL*a*b*colourconversion.
strstartswith.mtestsifastringstartswithaspecifiedsubstring.
strendswith.mtestsifastringendswithaspecifiedsubstring.
17 of 17
11/13/2010 09:08 AM