You are on page 1of 5
[Computer Graphics: By Raj Kumar Sharma (Aryabhatta College) Fill Area Algorithm, Fil tyes: ‘We ean spay a region wih ingle colour, a specifi fl pater, ora “ollow” syle by showing only the regions boundary. ‘We can ao fil selected scene regions using brush yes, eolor-blending combinations. or exues,Otber coptons include specifications fr the display of the Boundaries of fl rea. For poygous. we could show ‘he edges in deen colors, wits, and ses: and we can select vious display atebutes for aeons foot and back faces ‘Genera Scan-Line Polgon-il Algorithm ‘A scale lof region is perfomsed by fst dtenninias the intersection positon of he boundaries of he fl region with the scream scan lines, Then te fl eslous at applied to exch section of sc ine win the inveror of the fil egon. The scan-ln fil algorithm iene the sae interior regions as the o-even rl, “Theses eat ils a plyaon becase each sani nesecton pot wih a polyaon boundary bined by slviag a pi of stitaneus near equations Intestin ova an es ates oboe es Senne yew cube eae bat 8 iy otras ne amir eos aonb fare rome er pet as Fie 7 shows vo aca es ht cos a plyzon ae diet ete Seam ie Ines evensbet of ees and theo pis of ‘nenesion pt slong hs amie caret wen {us orr pst spans Busca ine vse Se Dolo es. To Keni the ero les fo sea Ke etait cua the verte eset nl ne Pit Ts we ms sings Batwesn ee ese 0 Weproces san es Inert alonga san nepasing aug pogo ae ‘We can detet the topological diferenceberen san fine» nd scan ine y" ‘mn Figuce 47 by noting the poston of the nerseting edges relative othe scan line. For sean line, he two edges sting an intersection vate are on opps Ses of the scan line. Bur for saa ney ‘he to itersecing edges are Doth above the sean ine “Thus a vertex with adjoining edges on oppose sides of an futersevtng sean line sold be come sot one Boundary Iersection pout. We can deny these wrices by ting sound the poyzon boundary in ier cockvieeorcousterlockwise order and observing the felaive changes in vertex coordinates as we move on ene ‘geo the next. Suppose the tee endpoint y vals of 180 ‘consecutive edges monotony ncrese o decree, In hat "he, ed coil he sed (mill) verona sale Intersection pot forte scan line passing troush tha vertex. Oorwie the sbared vertex represent local ‘etremu (misinuyn or maxinnm) onthe polygon bouday, fd the 10 ed rpersectons wit he scan line passing through that ‘verte ca be ade to the iaterersin st ‘One method for adjusting th vres:inrscton coun isto shorten ‘some polygon edges to split those vertices thar should be counted as one lntenaction. We can procee senhoriontl edges arond hepa ‘ound nthe ode specie eer clockwise or couerlocke, aswe Fioure a8 ‘using era y ales 3 polar 2 we resend ScanLiney 1 Sunde pehgo pee Ie mLiney ee coer bing proceed = ‘ead eso re nf ey Scan Liney 1 Gouda te vpe ep o ‘Mee edges eased y Tn {t,he orate of he use at te et ee dees an [Computer Graphics: By Raj Kumar Sharma (Aryabhatta College) ‘Green ug ae eoee angrier nae peer tie etic Seiten etna aan swash ecu Ane Proce each edge we can check weer at edge an the nex noahoricntal edge have eter monotonically inreasing ot dectesing endpoint valves. so, he lower edge ca be sowtened to eure chav only one intersection poi is eneated ex the sean line going trough the coumen vertex joining the two ees. Figure 48 illustrates the shortening of mn eda ‘When th endpoint coordinates ofthe Reo edges ae increasing they vale ofthe per endpoint er the caret eae ocrease by I asin Figure (a). When to endpoint valves are manotoncally deeeasne asin Figure 8(0). we decrease they Coordinate ofthe upper endpoint ofthe edge following the curent de Fajen y ales ora pobon awe poses een er Sean Liney +1 Sow he cao peti Te ScaaLiey elect Beng ocd s inated cite hey Scan Liney 1 Gute o be uper aceon recanted ceased yn (Ge y cornet be uppr tpt ten edge cece yt Sem Line +1 Tn sue anes nrg _apolmonboontan, “Typically, contain properties of one pat ofa scone ae relat in some way to the ropes in oir ps of the scene. These ‘coherence properties can be sed in computer srphics algrims to reduce processing. Coherence mtiods ‘often ivolve incremental calculations applied along a sige scan lin or btveen successive sca ins. For example, i ‘eterna lates edge itersections, We ca setup inerementl coordinate cleans slong ay edge by explsting the ‘Act hatte slope ofthe edge is onan fom one sean ie fo the nex. gute 4 sows wo shecesve scan ies eosin the Jef edge of ui. The slope of tis ede can be exresedin terns ofthe eatin intersection coordinates ey 64 -y 10K =k) mere kT Y= ‘Scan-Line Fi of Convex Polygons: ‘Scan-Lne Fl for Regions with Curved Boundaries oVshiple Sve: Seis ces oF eps we ean apply il methods similar to thse for convex polygons. Each sca ie crossing a ale or lipse Interior has just wo boundary intersections. We can determine these 60 ‘nrc point along the Boundary of circle or an elips sing incremental Ccleuatous tthe midpoitt method. Then we fli the horizontal, RGUREIET pie sane fou one itersecton pot othe ote, Snares between Farr la lip . ‘qadras(anébarween cents fo eles) ae used edace the boundary ‘aleulaous Similar methods can generate ill area for a curve section For example, an area ‘bounded by an lpia arc and a sigh line section (Figure 51) canbe filled ‘sing a combinstion of curve and lie procedures. Symmetries and incremental ‘aleuatious are exploited whenever possible fo reduce computations. Fil Methods for Areas with Wrogular Boundaries Another approach fo filing a specified acento start at an inside poston and “pint the nei, point by pont, out te bounty “Thisisa parculcy sel ectique fo ing eas wit gular borders. such asa design cested with pin rogran. Genel. these metods reuse an input staring postion inside the area to be filed and sone color iferaton about ee the boundary or the Boundary Fill Algorithm ‘the boundary of some resin s specifi in a ingle colo, we ca fil he interior ofthis egon. piel by piel, ui he boundary color {is encountered. This We can il ireglar regions wh single cole or witha color pater. Fora pater El we overlay a color mask. As ‘ach pel within the raion is processed. color is dtc’ by te estrexpords aks in the ove por, ‘The boundary fl algorithm is employed interactive punting packages, whee ition pots te esl selected, Using graphics tablet rote iterative device at att o designer can seth igre cline, sel fil eolur ftom 8 colour men. specify the ‘ren Boundary colour. ad pik an ineior point. The figure inter i then piste in il colour. Both ier aad outer tondaies canbe Se up te define an area fr boundary fil, and Figure £2 itt examples for specifying colour regions a xX @ ‘sample fo Eee for ound fl pace emotion Seaentinna ] Bsc, bounda-flslzoritn srs fom annex pont (x) and ess the cle of neighboring psitons teed pono not splayed st the boundary clr sce mgd othe i lr a sighs ane est Tis procodure cornues ul al pil ae processed pi the desighfled bound color fr he ae Figure 53 shows two methods for processing neighboring pixels from a cusret test poston In igure SO), four negborng pon ar sed, These co fre ie peel posers tu ae righ above, and eow te carer ps ‘Kas tled by dus eed ar led tonmecte. The sand method, shown u inure 900, (sused toil morecomplex igus Heretheset of megboring, _positions tobe tested includes the four diagonal pixels, as well as thane in the andinal directions, Fill methods using this approach ate called connected. An ‘connected boundary-fil algorithm would corte il the interior of the area dlfined in Figure 3, but aonnected boundary-fl algorithm would fl only pat ofthat gion. ‘The following procedure illustrates a recursive method for painting. a “connected area witha solid color, specified in parameter £421Colee, up to ‘boundary color specified with parameter bordezColer, We can extend this pproceiae to fill an Seconnected region by ineling four addtional statements to test the diagonal postions (x1, v1), Filet spe2 corso seGlarcmantamecdaes {Silo recat so ‘Sot Psion ob ton aod o) o ‘An cxample of how pi spans could be fie using hs approach sisted forthe connected fil elon in Figen this example, we acess process sca nes fom th str ie fo the top booms Aer ll per sem ins ae proceed ‘we Glia he pine! space ete vai scan ines i de on othe betes boundary. The lot pal pain ar ach ‘ovizewal sans located and stacked ia leftosighr ed cose successive sean es. 5 showa in Fi Sn) of is igre. the intl span as bees ied nd siaing postions | and? for spas on th px sean Tins (Dl nd above) are stacked nT (0), poston to has been unsacked and roseedo produce te filed pan shown, andthe starting pixel (poston 3) forte single span on the nex sea ine as Horn tacked er poston the is roceseed, th led spans ane Sacked postions ae sown in Figure 856) Figte $50) shows the filed pels ae processing als nthe ue sit orion OY he seid are Postion Sis ext procesed and spans a fled ae upper portion of he ea ca poston Tou pike pf cote the proces Fre ower sea bes. cerns ‘atc i Exec ac pa Scrat ae ene ‘ih a hn ont spar ren ‘atesaes paso ‘foment cons ed Felons tteanite doe febealenter tem eum oe na Fp : Steasaneseeco une does cones fi ae oe gh tn {ete ep Be ‘eng ers fom [Computer Graphics: By Raj Kumar Sharma (Aryabhatta College) Tote Implementation Methods for Antiiasing {ine seaments an oer graphics primitives generated by the raster algorithms discussed earlier in this chapter ve a jagged or snr-tep.eppesrncebecae the sampling proces dpc coordinate points onan objeto dart meget pel posoas. This distortion of formation du o1ow-Sequescy sapling (wadesamplig) is called sas We ca Etuprve the appeatnce of displayed vases ines by applying antaaing mato thet cones forthe wadersampling proces. An example ofthe ffs of mndersampting ft shosm i Fie 58. To avoi los sfomaton from seh peso ‘Sbjers, We ied Tost the sampling Beqency To east ice a ofthe highest Hequency occuring athe objet, referred to asthe Nyquist sampling frequency (or Nyquist sampling ae) =/6= 2 ows ‘one way increase he sampling ae with ase syste is to dpa objets at higher resolution, However, even wih cure ‘ecology’ highest esluion possible, the juaies willbe appre fo some exe. Tete iio hv bg we ean ake the ‘Mame buffer and main the effesh ate at 6 frames ot moe per second. We need arta sal sampling interval fo represent objects accursely with continuous parameters. Therfere,hardareechuclogy is equ to bande arbivaly rae ‘Mane buffers, and increased seroen resolu is uot a complete sliaion tothe alsin robles NMA Oh TAN AN LSete Ete nittnte soreawear tae % a A stmightforward antliasing method increases the sampling rte by treating the sree a if it were covered with 2 finer eid than is svalsble. We can then nse nul sample pons across this finer grid to deri an appropriate ints vel foreach cron isl, Thi ecluigue of ramping object characteris a high escluon and @. ‘Assuming we know the values for F and B, we ean check the current contents ofthe frame butfer to determine how these colors were combined. The cutrent ‘olor Pot each piel within the area to be refilled is some linear combination of F and Pairs -9B oa) where the transparency factor t has a value between O and 1 for each pivel. For values of less than 05, the background color contributes more to the interior Color of the region than daes the fill color If our color values are represented using Separate red, een, and blue (RGB) components, Equation 64 holds for plement Algorithm for Graphics Prine and Atri eo *3 we eee = Seite, ere ea a cach component ofthe coors, with Pe Pe, Po, Pa), F=(Fe, Fo. Fe (Be, Be, Be) (65) ‘We can thus calelae the Value of parameter Fusing one of the RGB color com- ponents as follows AWB AaB R,G,or B; and F; # B, Theoretically parameter thas the same value foreach RGB component, but the round calculations #9 obtain inter codes cn result incferen values for different components. We can minimize this ‘roundoff eror by selecting the component with the largest difference between Fand B. This value off then used fo mix the new fil olor NF withthe back- ground color Wecan accomplish this mixing sing ether a moeliied flood-fil or bboundary-fil procure, as described in Section 13, ‘Sinile color blending procedures can be applied to an area whose foe= ground color isto be mengecl with multiple background color areas, such a8 a ‘checkerboard pattern, When two background colors By and By ane mixed with foreground color F, she resulting pixel color Pis OF + iB) +06 —A)Bs on ‘where the sum of the colorterm coefficients ff, al (1 — fo ~ 4) must equal 1, We can set up two simileaneis equations using two of the tee RGB color ‘components to solve forthe two proportionality parameters, fy and fy. These [parameters are then sed to mix the new illcolo with the two background colors "oobi he new pss color. Wit thee bekgtovnd colors md one freon olor, cr ‘wh wo background and to Zvepound colt, ve noel dee RGB equations te cain ‘he tele anit ofthe fone clos For some forego’ an bckgrown calor nubitoas, however, the sen fo cr thee RGD eqns cannot be sed, TR occurs wha the color values ral very sana or Whe dey ate al proportional 1 each ‘tee 9)

You might also like