Introduction to computer graphics - Copy.pdf

OwoeyeShina 242 views 99 slides May 05, 2024
Slide 1
Slide 1 of 99
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76
Slide 77
77
Slide 78
78
Slide 79
79
Slide 80
80
Slide 81
81
Slide 82
82
Slide 83
83
Slide 84
84
Slide 85
85
Slide 86
86
Slide 87
87
Slide 88
88
Slide 89
89
Slide 90
90
Slide 91
91
Slide 92
92
Slide 93
93
Slide 94
94
Slide 95
95
Slide 96
96
Slide 97
97
Slide 98
98
Slide 99
99

About This Presentation

Introduction to computer graphics


Slide Content

CSC 407 Computer
Graphics
Olufemi AKINYEDE, PhD

Course Description
ComputerGraphics:ApplicationofComputer
Graphics,InteractiveandPassiveGraphics;
GraphicSystems:DisplayProcessor,CathodeRay
Tube(CRT),RandomScanvsRasterScan,Color
CRTMonitors,DirectViewStorageTubes,Flat
PanelDisplayopenlink;Input-OutputDevices:
InputDevices,OutputDevices;ScanConversiona
line:ScanConversionDefinition,ScanConverting
aPoint,ScanConvertingaStraightLine,DDA
Algorithm,Bresenham'sLineAlgorithm;Scan
ConversionCircle:DefiningaCircle,Defininga
CircleusingPolynomialMethod.

Lecture 1

Introductionandoverview
•Computergraphicsisanartofdrawing
picturesoncomputerscreenswiththehelpof
programming.
•Itinvolvescomputations,creation,and
manipulationofdata.
•Inotherwords,wecansaythatcomputer
graphicsisarenderingtoolforthegeneration
andmanipulationofimages.
•Renderingorimagesynthesisistheprocessof
generatingaphotorealisticornon-
photorealisticimagefroma2Dor3Dmodel
bymeansofacomputerprogram.

Whycomputergraphicsisimportant
•Computergraphicsisresponsiblefor
displayingartandimagedataeffectivelyand
meaningfullytotheconsumer.
•Itisalsousedforprocessingimagedata
receivedfromthephysicalworld,suchas
photoandvideocontent
Why?
•Weneedtoproduceappealingpictures.
•Humansrespondbettertopictorial
information.
•Humanbrainrecognizesvisualpatterns.

Computergraphicstools…
CGtoolsincludehardwareandsoftwaretools.
•Thehardwaredevicesusedforthecomputer
graphicsare:
•InputDevices:Keyboard,Mouse,Datatablet,
Scanner,Lightpen,Touchscreen,Joystick
•OutputDevices:RasterDevices-CRT,Liquid
CrystalDisplay(LCD),Light-EmittingDiode
display(LED),Plasmascreens,Printers,
VectorDevices-Plotters,Oscilloscopes.

Computergraphicstools…
Softwaretools.
•Operatingsystem.graphics-basedoperating
systeminterfaceusesicons,menusandamouse
tomanageinteractionwiththesystem
•Complier.Ithelpstocompilesourcecodeand
executeit.
•Editor.Itallowsuserstoeditandmanipulate
graphicalimagesthroughavarietyofmethods.
Thesetypesofeditorprogramsaretypically
dividedintooneoftwodifferenttypes:either
rastergraphicseditorsorvectorgraphicseditors.

Computergraphicstools…
Softwaretools…
•Debuggers.Itisacomputerprogramusedtotest
anddebugotherprograms.
•Graphicslibrary.Itisaprogramlibrarydesigned
toaidinrenderingcomputergraphicstoa
monitor.

Applicationsofcomputergraphics?
Theareasinwhichcomputergraphicsisusedinclude:
•ComputerArt.Usingcomputergraphicswecan
createfineandcommercialartwhichinclude
animationpackages,paintpackages.
•ComputerAidedDrawing.Designingof
buildings,automobile,aircraftisdonewiththe
helpofcomputeraideddrawing,thishelpsin
providingminutedetailstothedrawingand
producingmoreaccurateandsharpdrawings
withbetterspecifications.
•Visualization.Itisanytechniqueforcreating
images,diagrams,oranimationstocommunicate
messages.

•Medicaldiagnostics.Theuseofcomputer
graphicsformedicaldiagnosishasprovidedan
extraordinaryabilitytovisualize,measureand
evaluatestructuresinanon-intrusivemanner.
•Draftingandcomputerdesign.Computer-aided
draftinganddesignorCADD,istheuseof
softwaretodrawanddesignphysical
componentsortolayoutprocesses.It'san
importantpartofmanyindustries,including
architectureandengineering,becauseit
providespreciseinstructiononhowthings
shouldbemade.
Applicationsofcomputergraphics?…

•ImageProcessing.Processingofexisting
imagesintorefinedonesforbetter
interpretationisoneofthemanyapplications
ofCGs.
•MachineDrawing.Computergraphicsisvery
frequentlyusedfordesigning,modifyingand
creationofvariouspartsofmachineandthe
wholemachineitself,themainreasonbehind
usingCGforthispurposeistheprecisionand
claritywegetfromsuchdrawingisultimateand
extremelydesiredforthesafemanufacturingof
machineusingthesedrawings.
Applicationsofcomputergraphics?…

•Education.Usingcomputergraphicsmany
educationalmodelscanbecreatedthrough
whichmoreinterestcanbegeneratedamong
thestudentsregardingthesubject.
•Entertainment.Computergraphicsfindsa
majorpartofitsutilityinthemovieindustry
andgameindustry.Usedforcreatingmotion
pictures,musicvideo,televisionshows,cartoon
animationfilms.
•GraphicalUserInterface.Theuseofpictures,
images,icons,pop-upmenus,graphicalobjects
helpsincreatingauserfriendlyenvironment.
Applicationsofcomputergraphics?…

Lecture 2

Displaydevices
Themostcommonlyuseddisplaydeviceisa
videomonitor.Theoperationofmostvideo
monitorsbasedonCRT(CathodeRayTube).
Thefollowingdisplaydevicesareused:
•RefreshCathodeRayTube
•RandomScanandRasterScan
•ColorCRTMonitors
•DirectViewStorageTubes
•FlatPanelDisplay
•LookupTable

CathodeRayTube
•CRTstandsforCathodeRayTube.CRTisa
technologyusedintraditionalcomputer
monitorsandtelevisions.TheimageonCRT
displayiscreatedbyfiringelectronsfromthe
backofthetubeofphosphoruslocated
towardsthefrontofthescreen.
•Oncetheelectronheatsthephosphorus,they
lightup,andtheyareprojectedonascreen.
Thecoloryouviewonthescreenisproduced
byablendofred,blueandgreenlight.

CathodeRayTube…
MainComponentsofCRTare:
1.ElectronGun:Electrongunconsistingofa
seriesofelements,primarilyaheatingfilament
(heater)andacathode.Theelectrongun
createsasourceofelectronswhicharefocused
intoanarrowbeamdirectedatthefaceofthe
CRT.

CathodeRayTube…
2.ControlElectrode/Grid:Itisusedtoturn
theelectronbeamonandoff.
3.Focusingsystem/coil:Itisusedtocreatea
clearpicturebyfocusingtheelectronsinto
anarrowbeam.

CathodeRayTube…
4.Deflectionyoke/coil:Itisusedtocontrolthe
directionoftheelectronbeam.Itcreatesanelectric
ormagneticfieldwhichwillbendtheelectronbeam
asitpassesthroughthearea.InaconventionalCRT,
theyokeislinkedtoasweeporscangenerator.The
deflectionyokewhichisconnectedtothesweep
generatorcreatesafluctuatingelectricormagnetic
potential.

CathodeRayTube…
5.Phosphorus-coatedscreen:Theinsidefront
surfaceofeveryCRTiscoatedwith
phosphors.Phosphorsglowwhenahigh-
energyelectronbeamhitsthem.
Phosphorescenceisthetermusedto
characterizethelightgivenoffbyaphosphor
afterithasbeenexposedtoanelectron
beam.

Thereare2kindsofredrawing
mechanisms:Random-Scanand
Raster-Scan

RandomScanDisplay:
•RandomScanSystemusesanelectronbeam
whichoperateslikeapenciltocreatealine
imageontheCRTscreen.Thepictureis
constructedoutofasequenceofstraight-line
segments.Eachlinesegmentisdrawnonthe
screenbydirectingthebeamtomovefromone
pointonthescreentothenext,whereitsx&y
coordinatesdefineeachpoint.Afterdrawing
thepicture.Thesystemcyclesbacktothefirst
lineanddesignallthelinesoftheimage30to
60timeeachsecond.Theprocessisshownin
fig:

RandomScanDisplay…
•TheprocessofRandomScanDisplayisas
shownbelow.
Random-scan
monitorsarealso
knownasvector
displaysorstroke-
writingdisplaysor
calligraphicdisplays.

Advantages:
•ACRThastheelectronbeamdirectedonly
tothepartsofthescreenwhereanimageis
tobedrawn.
•Producesmoothlinedrawings.
•HighResolution
Disadvantages:
•Random-Scanmonitorscannotdisplay
realisticshadesscenes.
RandomScanDisplay…

•ARasterScanDisplayisbasedonintensity
controlofpixelsintheformofarectangular
boxcalledRasteronthescreen.Information
ofonandoffpixelsisstoredinrefreshbuffer
orFramebuffer.
•TelevisionsinourhousearebasedonRaster
ScanMethod.Therasterscansystemcan
storeinformationofeachpixelposition,soit
issuitableforrealisticdisplayofobjects.
RasterScanprovidesarefreshrateof60to
80framespersecond.
Raster-ScanDisplay.

•FrameBufferisalsoknownasRasterorbit
map.InFrameBufferthepositionsarecalled
pictureelementsorpixels.Beamrefreshingis
oftwotypes.Firstishorizontalretracingand
secondisverticalretracing.Whenthebeam
startsfromthetopleftcornerandreaches
thebottomrightscale,itwillagainreturnto
thetopleftsidecalledatverticalretrace.
Thenitwillagainmovehorizontallyfromtop
tobottomcallashorizontalretracingshown
infig:
Raster-ScanDisplay….

Raster-ScanDisplay….
InInterlacedscanning,eachhorizontallineofthescreenis
tracedfromtoptobottom.Duetowhichfadingofdisplayof
objectmayoccur.ThisproblemcanbesolvedbyNon-
Interlacedscanning.Inthisfirstofalloddnumberedlinesare
tracedorvisitedbyanelectronbeam,theninthenextcircle,
evennumberoflinesarelocated.
Fornon-interlaceddisplayrefreshrateof30framesper
secondused.Butitgivesflickers.Forinterlaceddisplayrefresh
rateof60framespersecondisused.

Raster-ScanDisplay….
TypesofScanningortravellingofbeaminRaster
Scan
1.InterlacedScanning
2.Non-InterlacedScanning
•InInterlacedscanning,eachhorizontallineof
thescreenistracedfromtoptobottom.Dueto
whichfadingofdisplayofobjectmayoccur.
ThisproblemcanbesolvedbyNon-Interlaced
scanning.Inthisfirstofalloddnumberedlines
aretracedorvisitedbyanelectronbeam,then
inthenextcircle,evennumberoflinesare
located.

Raster-ScanDisplay….
•Fornon-interlaceddisplayrefreshrateof
30framespersecondused.Butitgives
flickers.Forinterlaceddisplayrefreshrate
of60framespersecondisused.

Raster-ScanDisplay….
Advantages:
•Realisticimage
•MillionDifferentcolorstobegenerated
•ShadowScenesarepossible.
Disadvantages:
•LowResolution
•Expensive

DifferentiatebetweenRandomandRaster
ScanDisplay:

Lecture 3

ColorCRTMonitors
TheCRTMonitordisplaybyusinga
combinationofphosphors.Thephosphorsare
differentcolors.
Therearetwopopularapproachesfor
producingcolordisplayswithaCRTare:
1.BeamPenetrationMethod
2.Shadow-MaskMethod

ColorCRTMonitors
1.BeamPenetrationMethod:Thishasbeenused
withrandom-scanmonitors.Inthismethod,the
CRTscreeniscoatedwithtwolayersof
phosphor,redandgreenandthedisplayedcolor
dependsonhowfartheelectronbeampenetrates
thephosphorlayers.Thismethodproducesfour
colorsonly,red,green,orangeandyellow.Abeamof
slowelectronsexcitestheouterredlayeronly;
hencescreenshowsredcoloronly.Abeamof
high-speedelectronsexcitestheinnergreenlayer.
Thusscreenshowsagreencolor.

ColorCRTMonitors…
BeamPenetrationMethod
Advantages
1.Inexpensive
Disadvantages
1.Onlyfourcolorsarepossible
2.Qualityofpicturesisnotasgoodaswithanother
method.

ColorCRTMonitors…
2.Shadow-MaskMethod:.
•ShadowMaskMethodiscommonlyusedinRaster-
ScanSystembecausetheyproduceamuchwider
rangeofcolorsthanthebeam-penetrationmethod.
•ItisusedinthemajorityofcolorTVsetsand
monitors.
•Construction:AshadowmaskCRThas3phosphor
colordotsateachpixelposition.
•Onephosphordotemits:redlight
•Anotheremits: greenlight
•Thirdemits: bluelight
•ThistypeofCRThas3electronguns,oneforeach
colordotandashadowmaskgridjustbehindthe
phosphorcoatedscreen.

ColorCRTMonitors…Shadow-Mask
Method
•Shadowmaskgridispiercedwithsmallround
holesinatriangularpattern.
•Figureshowsthedelta-deltashadowmask
methodcommonlyusedincolorCRTsystem.

ColorCRTMonitors…Shadow-MaskMethod
Advantage:
•Realisticimage
•Milliondifferentcolorstobegenerated
•Shadowscenesarepossible
Disadvantage:
•Relativelyexpensivecomparedwiththe
monochromeCRT.
•Relativelypoorresolution
•ConvergenceProblem

DirectViewStorageTubes(DVST).
•DVSTterminalsalsousetherandom
scanapproachtogeneratetheimageon
theCRTscreen.
•Theterm"storagetube"referstothe
abilityofthescreentoretaintheimage
whichhasbeenprojectedagainstit,thus
avoidingtheneedtorewritetheimage
constantly.

DirectViewStorageTubes(DVST).
Functionofguns:Two
gunsareusedinDVST
1.Primaryguns:Itis
usedtostorethe
picturepattern.
2.Floodgun or
Secondarygun:Itis
usedtomaintain
picturedisplay.

DirectViewStorageTubes(DVST).
Advantage:
•Norefreshingisneeded.
•HighResolution
•Costisveryless
Disadvantage:
•Itisnotpossibletoerasetheselectedpartof
apicture.
•Itisnotsuitablefordynamicgraphics
applications.
•Ifapartofpictureistomodify,thentimeis
consumed.

FlatPanelDisplay
•TheFlat-Paneldisplayreferstoaclassof
videodevicesthathavereducedvolume,
weightandpowerrequirementcompareto
CRT.
•Example:SmallT.V.monitor,calculator,
pocketvideogames,laptopcomputers,an
advertisementboardinelevator.

FlatPanelDisplay…
1.EmissiveDisplay:Theemissivedisplaysare
devicesthatconvertelectricalenergyinto
light.ExamplesarePlasmaPanel,thinfilm
electroluminescentdisplayandLED(Light
EmittingDiodes).
2.Non-EmissiveDisplay:TheNon-Emissive
displaysuseopticaleffectstoconvert
sunlightorlightfromsomeothersource
intographicspatterns.ExamplesareLCD
(LiquidCrystalDevice).

Emissive-FlatPanelDisplay
PlasmaPanelDisplay:Plasma-Panelsarealso
calledasGas-DischargeDisplay.Itconsistsof
anarrayofsmalllights.Lightsarefluorescent
innature.
Theessentialcomponentsoftheplasma-paneldisplay
are:
1.Cathode:Itconsistsoffinewires.Itdelivers
negativevoltagetogascells.Thevoltageis
releasedalongwiththenegativeaxis.

FlatPanelDisplay…
Theessentialcomponentsoftheplasma-paneldisplay
are:
2.Anode:Italsoconsistsoflinewires.It
deliverspositivevoltage.Thevoltageis
suppliedalongpositiveaxis.
3.Fluorescentcells:Itconsistsofsmall
pocketsofgasliquidswhenthevoltageis
appliedtothisliquid(neongas)itemits
light.
4.GlassPlates:Theseplatesactascapacitors.
Thevoltagewillbeapplied,thecellwillglow
continuously.

FlatPanelDisplay…
•Thegaswillslowwhenthereisasignificant
voltagedifferencebetweenhorizontaland
verticalwires.Thevoltageleveliskept
between90voltsto120volts.Plasmalevel
doesnotrequirerefreshing.Erasingisdoneby
reducingthevoltageto90volts.
•Eachcellofplasmahastwostates,socellis
saidtobestable.Displayablepointinplasma
panelismadebythecrossingofthe
horizontalandverticalgrid.Theresolutionof
theplasmapanelcanbeupto512*512pixels.

FlatPanelDisplay…
Advantage:
•HighResolution
•Largescreensizeisalsopossible.
•LessVolume
•Lessweight
•FlickerFreeDisplay
Disadvantage:
•PoorResolution
•Wiringrequirementanodeandthecathodeis
complex.
•Itsaddressingisalsocomplex.

Emissive-LED(LightEmittingDiode)
InanLED,amatrixofdiodesisorganizedto
formthepixelpositionsinthedisplayand
picturedefinitionisstoredinarefreshbuffer.
Dataisreadfromtherefreshbufferand
convertedtovoltagelevelsthatareappliedto
thediodestoproducethelightpatterninthe
display.

NonEmissive-LCD(LiquidCrystalDisplay)
LiquidCrystalDisplaysarethedevicesthat
produceapicturebypassingpolarizedlight
fromthesurroundingsorfromaninternal
lightsourcethroughaliquid-crystalmaterial
thattransmitsthelight.
LCDusestheliquid-crystalmaterialbetween
twoglassplates;eachplateistherightangle
toeachotherbetweenplatesliquidisfilled.
Oneglassplateconsistsofrowsof
conductorsarrangedinverticaldirection

NonEmissive-LCD(LiquidCrystalDisplay)
Anotherglassplateisconsistingofarowof
conductorsarrangedinhorizontaldirection.
Thepixelpositionisdeterminedbythe
intersectionofthevertical&horizontal
conductor.Thispositionisanactivepartof
thescreen.
Liquidcrystaldisplayistemperature
dependent.Itisbetweenzerotoseventy
degreeCelsius.Itisflatandrequiresverylittle
powertooperate.

NonEmissive-LCD(LiquidCrystalDisplay)
Advantage:
1.Lowpowerconsumption.
2.SmallSize
3.LowCost
Disadvantage:
1.LCDs aretemperature-
dependent(0-70°C)
2.LCDsdonotemitlight;asa
result,theimagehasverylittle
contrast.
3.LCDshavenocolorcapability.
4.Theresolutionisnotasgoodas
thatofaCRT.

Lecture 4

Scan
Conversion a
line

ScanConversion
•Theprocessofrepresentingcontinuous
graphicsobjectasacollectionofdiscrete
pixelsisknownasscanconversion.Each
pixelcanhaveeitheronoroffstate.
•Thecircuitryofthevideodisplaydeviceof
thecomputeriscapableofconvertingbinary
values(0,1)intoapixelonandpixeloff
information.
•0isrepresentedbypixeloff.
•1isrepresentedusingpixelon.

ScanConversion…
Theprocessofscanconversionrequiressomebasicrules
andguidelines:
1.Alltheobjectsdrawnonthegraphicsscreen
shouldbeofuniformbrightness.The
brightnesscontentmustbethesameforevery
pointsothattheconversionismadeeasy.
2.Theobjectsdrawnonthegraphicsscreen
shouldbefreefromanyorientationand
independentoflengthandsize.

ScanConversion…
•Pixels.Apixelisthesmallestunitofa
graphicsimageorreferredtoasaphysical
pointinaraster.Thisisthecomponentof
theoriginalgraphicsimagewhichprovides
evenmoreclearrepresentationthanthe
originalimage.
•Theintensityofeachpixelmayvaryasit
dependsontheimagerepresentedinthe
graphicsimageandthecolorcombinationis
representedbythethreebasiccolorsthatare
red,greenandblue.

ScanConversion…
•Pixelsarealsodefinedasthesmallest
addressableunitorelementofthescreen.
Eachpixelcanbeassignedanaddressas
showninfig:

ScanConversion…Pixel
•Differentgraphicsobjectscanbegenerated
bysettingthedifferentintensityofpixelsand
differentcolorsofpixels.Eachpixelhas
someco-ordinatevalue.Thecoordinateis
representedusingrowandcolumn.
•P(5,5)usedtorepresentapixelinthe5th
rowandthe5thcolumn.Eachpixelhassome
intensityvaluewhichisrepresentedin
memoryofcomputercalledaframebuffer.
FrameBufferisalsocalledarefreshbuffer.

ScanConversion…Pixel
•Thismemoryisastorageareaforstoringpixels
valuesusingwhichpicturesaredisplayed.Itis
alsocalledasdigitalmemory.
•Insidethebuffer,imageisstoredasapattern
ofbinarydigitseither0or1.Sothereisan
arrayof0or1usedtorepresentthepicture.
•Inblackandwhitemonitors,blackpixelsare
representedusing1'sandwhitepixelsare
representedusing0's.Incaseofsystems
havingonebitperpixelframebufferiscalleda
bitmap.Insystemswithmultiplebitsperpixel
itiscalledapixmap.

ScanConversion…
Scanconversionisdoneusingtwomethodsortechniques.
1.Analogmethods:Thisconversionisdone
forlargenumbersofdelaycellsandis
appropriateforananalogvideo.Itmaybe
performedalsousingaparticularspecialized
scanconvertervacuumtube.Inthiscase,all
polarcoordinatesi.e.(Angleanddistance)
datafromasourcesuchasaradarreceiver,
sothatitcanbedisplayedonanyrasterscan
display.

ScanConversion…
Scanconversionisdoneusingtwomethodsortechniques.
2.Digitalmethods:Inthisparticularmethod,
anypictureisstoredinalineorframebuffer
withn1speed(datarate)andisreadwithn2
speed,severalpictureprocessingtechniques
areapplicablewhenthepictureisstoredin
buffermemoryincludingkindsof
interpolationfromsimpletosmarthigh
ordercomparisons,motiondetectionandto
improvethepicturequalityandpreventthe
conversioncomplications.

ScanConversion…
Scanconversionisdoneusingtwomethodsortechniques.
2.Digitalmethods:Inthisparticularmethod,
anypictureisstoredinalineorframebuffer
withn1speed(datarate)andisreadwithn2
speed,severalpictureprocessingtechniques
areapplicablewhenthepictureisstoredin
buffermemoryincludingkindsof
interpolationfromsimpletosmarthigh
ordercomparisons,motiondetectionandto
improvethepicturequalityandpreventthe
conversioncomplications.

ScanConversion…
Needofscanconversionalgorithms
•Thishelpsinacceleratingtheprocessofscan
conversionandcangenerategraphicobjects
atafasterratecomparatively.Usingthese
algorithmsmemoryisalsousedefficiently
andtheproductionqualityoftheobjectson
thescreenisalsoimproved.

ScanConversion…
Needofscanconversionalgorithms….
•Wecanusearandomscansystemforthis
process.Itusesabeamofelectronsthatare
acceleratedthroughthepotentialdifference
andoperateslikeapencilonthescreenof
thecathoderaytubethusproducingobjects
onthescreen.Theseareconstructedthrough
aparticularsequenceoflinesdrawn.
•TheScanConvertingrateisatechniquethat
isusedinvideoprocessing.Inthistechnique,
wecanchangethehorizontalandvertical
frequenciesfordifferentpurposes.

ScanConversion…
Wecanapplythescanconversionalgorithmfor
variousobjectsthatare
Point,Line,Polygon(examplerectangle,
triangleandmanymore),Circle,Arc,
Sector,Anyfilledregion.

ScanConversion…
AdvantagesofScanConversion
1.Algorithmscangenerategraphicsobjectsat
afasterrate.
2.Usingalgorithmsmemorycanbeused
efficiently.
3.Algorithmscandevelopahigherlevelof
graphicalobjects.

ScanConversion…
DisadvantagesofScanConversion
1.Whiledigitalscanconversion,theanalog
videosignalgetsconvertedintodigital
signalsofdata.
2.WecanapplyscanconversionwithonlyLSI
(LargeScaleIntegration)andVLSI(Very
LargeScaleIntegration)integratedcircuits.

ScanConvertingaStraightLine
•Astraightlinemaybedefinedbytwo
endpoints&anequation.Infigthetwo
endpointsaredescribedby(x
1,y
1)and(x
2,y
2).
Theequationofthelineisusedtodetermine
thex,ycoordinatesofallthepointsthatlie
betweenthesetwoendpoints.

ScanConvertingaStraightLine
•Usingtheequationofastraightline,y=mx
+b
•wherem=ScanConvertingaStraightLine&
•b=theyinterrupt,wecanfindvaluesofy
byincrementingxfromx=x
1,tox=x
2.
•Byscan-convertingthesecalculatedx,y
values,werepresentthelineasasequenceof
pixels.

Lecture 5

ScanConvertingaStraightLine
AlgorithmforlineDrawing:
1.DirectMethod
2.Bresenham'sAlgorithm
3.DDA(DigitalDifferentialAnalyzer)

ScanConvertingaStraightLine
1.DirectMethod.Itisthesimplestmethodof
this.Inthisalgorithm,wehavetwoendpoints.
Wefindtheslopeofthelinebyusingboth
thepointsandweputtheslopeintheline
equationY=MX+C.Thenwefindthe
valueofCbyputtingXandYisequalto0.
Afterthis,wehavearelationbetweenXand
Y.NowweincreasethevalueofXandfind
thecorrespondingvalueofY.Thesevalues
willbetheintermediatepointsoftheline.
Afterfindingtheintermediatepointswe'll
plotthosepointsanddrawtheline.

ScanConvertingaStraightLine
Algorithmfordrawinglineusingequation:
Step1:StartAlgorithm
Step2:Declarevariablesx1,x2,y1,y2,dx,dy,m,b,
Step3:Entervaluesofx1,x2,y1,y2.
The(x1,y1)areco-ordinatesofastartingpointoftheline.
The(x2,y2)areco-ordinatesofaendingpointoftheline.
Step4:Calculatedx=x2-x1
Step5:Calculatedy=y2-y1
Step6:Calculatem=
Step7:Calculateb=y1-m*x1
Step8:Set(x,y)equaltostartingpoint,i.e.,lowestpointandxend
equaltolargestvalueofx.
Step9: Check whether the complete line has been drawn if x=xend, stop
Step10: Plot a point at current (x, y) coordinates
Step11: Increment value of x, i.e., x = x+1
Step12: Compute next value of y from equation y = mx + b
Step13: Go to Step9.

Scan Converting a
Straight Line …
Program to draw a line using LineSlopeMethod
1
#include<graphics.h>
#include<stdlib.h>
#include<math.h>
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
classbresen
{
floatx,y,x1,y1,x2,y2,dx,dy,m,c,xend;
public:
voidget();
voidcal();
};
voidmain()
{
bresenb;
b.get();
b.cal();
getch();
}
Voidbresen::get() 2
{
print("Enterstart&endpoints");
print("enterx1,y1,x2,y2");
scanf("%f%f%f%f",sx1,sx2,sx3,sx4)
}
voidbresen::cal()
{
intgdriver=DETECT,gmode,errorcode;
initgraph(&gdriver,&gmode,"");
errorcode=graphresult();
if(errorcode!=grOK)

ScanConvertingaStraightLine
{
printf("Graphicserror:%s\n",grapherrormsg(errorcode);
3
printf("Pressanykeytohalt:");
getch();
exit(1);
}
dx=x2-x1;
dy=y2-2y1;
m=dy/dx;
c=y1-(m*x1);
if(dx<0)
{
x=x2;
y=y2;
xend=x1;
}
else 4
{
x=x1;
y=y1;
xend=x2;
}
while(x<=xend)
{
putpixel(x,y,RED);
y++;
y=(x*x)+c;
}
}

2.Bresenham'sAlgorithm.Thismethodofline
drawingisveryeffectivebecauseitincludes
integeraddition,subtraction,and
multiplication.Thecalculationisveryfastin
thismethodthat'swhythelineisdrawnvery
quicklyinthis.We'llneedthetwoendpointsin
thisandthenwehavetofindthedecision
parameters.Letassumethat(x
1,y
1)and
(x
2,y
2)arethetwopoints.So,dx=x
2-x
1and
dy=y
2-y
1.
•Theformulaforthedecisionparameteris:di=
2dy-dx
ScanConvertingaStraightLine

ScanConvertingaStraightLine..
Bresenham'sAlgorithm
•Thisisthewaywe
can findthe
intermediatepoint
andafterfinding
thesepointswecan
plotallthepointson
thescreenusing
programming.

... Bresenham's
Algorithm

... Bresenham's
Algorithm

... Bresenham's
Algorithm

... Bresenham's
Algorithm
Similarly,Step-03isexecuteduntiltheendpointis
reachedornumberofiterationsequalsto4times.
(Numberofiterations=ΔX–1=5–1=4)

... Bresenham's
Algorithm
X
k+1
Y
k+1

... Bresenham's
Algorithm

... Bresenham's
Algorithm

... Bresenham's
Algorithm
X
k+1
Y
k+1

Bresenham'sAlgorithm
Advantages
•Itiseasytoimplement.
•Itisfastandincremental.
•ItexecutesfastbutlessfasterthanDDAAlgorithm.
•Thepointsgeneratedbythisalgorithmaremore
accuratethanDDAAlgorithm.
•Itusesfixedpointsonly.
Disadvantages
•Thoughitimprovestheaccuracyofgeneratedpoints
butstilltheresultedlineisnotsmooth.
•Thisalgorithmisforthebasiclinedrawing.
•Itcannothandlediminishingjaggies

Lecture 6

DDAAlgorithm
DDAstandsforDigitalDifferentialAnalyzer.
Itisanincrementalmethodofscan
conversionofline.Inthismethodcalculation
isperformedateachstepbutbyusingresults
ofprevioussteps.

DDA Algorithm
….

DDAAlgorithm….

DDAAlgorithm….

DDAAlgorithm….
Example:Ifalineisdrawnfrom(2,3)
to(6,15)withuseofDDA.Howmany
pointswillneededtogeneratesuchline?

DDAAlgorithm….
Example:Calculatethepointsbetween
thestartingpoint(5,6)andending
point(8,12).

DDAAlgorithm….
X
p+1
Y
p+1

DDAAlgorithm….
Example:Calculatethepointsbetween
thestartingpoint(5,6)andending
point(13,10)

DDAAlgorithm….
Example:Calculatethepoints
betweenthestartingpoint(5,6)
andendingpoint(13,10)
X
p+1
Y
p+1

DDAAlgorithm….
Example:Calculatethepoints
betweenthestartingpoint(1,7)
andendingpoint(11,17).

DDAAlgorithm….
Example:Calculatethepoints
betweenthestartingpoint(1,7)
andendingpoint(11,17).
X
p+1
Y
p+1

DDAAlgorithm….
The advantagesof DDA Algorithm are-
•It is a simple algorithm.
•It is easy to implement.
•It avoids using the multiplication operation which is
costly in terms of time complexity.
ThedisadvantagesofDDAAlgorithmare-
•Thereisanextraoverheadofusingroundoff()
function.
•Usingroundoff()functionincreasestime
complexityofthealgorithm.
•Resultedlinesarenotsmoothbecauseofround
off()function.
•Thepointsgeneratedbythisalgorithmarenot
accurate.

Next time:
begins examination