raster

Attribution Non-Commercial (BY-NC)

11 views

raster

Attribution Non-Commercial (BY-NC)

- Computer Graphics Notes - Unknown
- Using Chart Designer to Customize Business Graphics in Web Dynpro Java
- ECE Matlab DIP Proj. Titles Abstracts)
- AA " fY1a0V ,lIaU'Nr;Ch 77'
- Evermotion Archmodels 99 PDF
- Data Interpretation
- 9780240809533_cs
- Graphics (Single).doc
- Bina Cg Resume Copy
- stephenie schweighardt resume
- Fa Ti Ma
- Using GIMP to Create an Artistic Regional RPG Map - Part 1
- Communication Skills
- Designing Great Visual Communications
- Understanding Graphicacy.docx
- Year 9 Term 3
- Pencil
- featurearticle 1
- ratzlaff digital unit plan
- Course Outline

You are on page 1of 25

2D Graphics Pipeline

Clipping Object World Coordinates Applying world window Object subset window to viewport mapping

Object Screen coordinates

Display

Rasterization

n n n

Convert high-level geometry description to pixel colors in the frame buffer Example: given vertex x,y coordinates determine pixel colors to draw line Two ways to create an image:

n n

Viewport Transformation

Rasterization

A fundamental computer graphics function Determine the pixels colors, illuminations, textures, etc. Implemented by graphics hardware Rasterization algorithms

n n n n

n n n n

Rasterization Operations

n n n n

Drawing lines on the screen Manipulating pixel maps (pixmaps): copying, scaling, rotating, etc Compositing images, defining and modifying regions Drawing and filling polygons

n

n n n n n

n n n

Programmer specifies (x,y) values of end pixels Need algorithm to figure out which intermediate pixels are on line path Pixel (x,y) values constrained to integer values Actual computed intermediate line values may be floats Rounding may be required. E.g. computed point (10.48, 20.51) rounded to (10, 21) Rounded pixel value is off actual line path (jaggy!!) Sloped lines end up having jaggies Vertical, horizontal lines, no jaggies

8 7 6 5 4 3 2 1

0 1 2 3 4 5 6 7 8 9 10 11 12

n n

y = mx + b Given two end points (x0,y0), (x1, y1), how to compute m and b?

dy y1 y 0 m= = dx x1 x0

(x1,y1)

dy

b = y 0 m * x0

(x0,y0)

dx

n n

Numerical example of finding slope m: (Ax, Ay) = (23, 41), (Bx, By) = (125, 96)

Walk through the line, starting at (x0,y0) Constrain x, y increments to values in [0,1] range Case a: x is incrementing faster (m < 1) Step in x=1 increments, compute and round y Case b: y is incrementing faster (m > 1) Step in y=1 increments, compute and round x

m>1 (x1,y1)

dy

m=1 m<1

(x0,y0)

dx

y k +1 = y k + m

(x1,y1)

x = x0

y = y0

Until x == x1

(x0, y0)

x k +1

1 = xk + m

x = x0 (x1,y1)

y = y0

(x0,y0) Until y == y1

compute m; if m < 1: { float y = y0; // initial value for(int x = x0;x <= x1; x++, y += m) setPixel(x, round(y)); } else // m > 1 { float x = x0; // initial value for(int y = y0;y <= y1; y++, x += 1/m) setPixel(round(x), y); } n Note: setPixel(x, y) writes current color into pixel in column x and row y in frame buffer

DDA is the simplest line drawing algorithm

n n

Not very efficient Round operation is expensive Integer DDA E.g.Bresenham algorithm (Hill, 10.4.1) Incremental algorithm: current value uses previous value Integers only: avoid floating point arithmetic Several versions of algorithm: well describe midpoint version of algorithm

n n

Bresenham algorithm

n n n

n n

Problem: Given endpoints (Ax, Ay) and (Bx, By) of a line, want to determine best sequence of intervening pixels First make two simplifying assumptions (remove later):

n n

Define

n n

(Ax,Ay)

n

Based on assumptions:

n n

n n n

As x steps in +1 increments, y incr/decr by <= +/1 y value sometimes stays same, sometimes increases by 1 Midpoint algorithm determines which happens

(x1,y1) What Pixels to turn on or off? Consider pixel midpoint M(Mx, My) M = (x0 + 1, Y0 + ) Build equation of line through and compare to midpoint

M(Mx,My)

(x0, y0)

n

(Bx,By) (x,y)

y Ay H = x Ax W

n n n n n

(Ax,Ay)

H(x Ax) = W(y Ay) -W(y Ay) + H(x Ax) = 0 Above is ideal equation of line through (Ax, Ay) and (Bx, By) Thus, any point (x,y) that lies on ideal line makes eqn = 0 Double expression (to avoid floats later), and give it a name, F(x,y) = -2W(y Ay) + 2H(x Ax)

So, F(x,y) = -2W(y Ay) + 2H(x Ax) Algorithm, If:

n n

n n

F(x, y) < 0, (x, y) above line F(x, y) > 0, (x, y) below line

n n

Hint: F(x, y) = 0 is on line Increase y keeping x constant, F(x, y) becomes more negative

Example: to find line segment between (3, 7) and (9, 11) F(x,y) = -2W(y Ay) + 2H(x Ax) = (-12)(y 7) + (8)(x 3)

n n n

For points on line. E.g. (7, 29/3), F(x, y) = 0 A = (4, 4) lies below line since F = 44 B = (5, 9) lies above line since F = -8

(x1,y1) What Pixels to turn on or off? Consider pixel midpoint M(Mx, My) M = (x0 + 1, Y0 + ) If F(Mx,My) < 0, M lies above line, shade lower pixel (same y as before)

M(Mx,My)

(x0, y0)

Initially, midpoint M = (Ax + 1, Ay + ) F(Mx, My) = -2W(y Ay) + 2H(x Ax) = 2H W Can compute F(x,y) for next midpoint incrementally If we increment x + 1, y stays same, compute new F(Mx,My) F(Mx, My) += 2H If we increment x +1, y + 1 F(Mx, My) -= 2(W H)

Bresenham(IntPoint a, InPoint b) { // restriction: a.x < b.x and 0 < H/W < 1 int y = a.y, W = b.x a.x, H = b.y a.y; int F = 2 * H W; // current error term for(int x = a.x; x <= b.x; x++) {

setpixel at (x, y); // to desired color value

if F < 0

F = F + 2H;

else{

Y++, F = F + 2(H W)

} }

n

Final words: we developed algorithm with restrictions 0 < m < 1 and Ax < Bx Can add code to remove restrictions

n n n n

To get the same line when Ax > Bx (swap and draw) Lines having m > 1 (interchange x with y) Lines with m < 0 (step x++, decrement y not incr) Horizontal and vertical lines (pretest a.x = b.x and skip tests)

References

n

Hill, chapter 9

- Computer Graphics Notes - UnknownUploaded byHarsh Vardhan Jha
- Using Chart Designer to Customize Business Graphics in Web Dynpro JavaUploaded bysiddhumesh1
- ECE Matlab DIP Proj. Titles Abstracts)Uploaded byACTS TECHNO SOLUTIONS
- AA " fY1a0V ,lIaU'Nr;Ch 77'Uploaded byiNdioNicarao
- Evermotion Archmodels 99 PDFUploaded byAlyssa
- Data InterpretationUploaded byNAGU N
- 9780240809533_csUploaded byLisa Johnson
- Graphics (Single).docUploaded bygulanchi
- Bina Cg Resume CopyUploaded byBabak Bina
- stephenie schweighardt resumeUploaded byapi-354345989
- Fa Ti MaUploaded byFatima Clemene Vergabera
- Using GIMP to Create an Artistic Regional RPG Map - Part 1Uploaded byshaun
- Communication SkillsUploaded byFredsmith647
- Designing Great Visual CommunicationsUploaded byIndrėKasputytė
- Understanding Graphicacy.docxUploaded byZakiah Dania
- Year 9 Term 3Uploaded bySally Eato-Corben
- PencilUploaded byJorge Gutierrez
- featurearticle 1Uploaded byapi-246070885
- ratzlaff digital unit planUploaded byapi-370137027
- Course OutlineUploaded bykwabena
- DOC-20180404-WA0003Uploaded byRavi Martolia
- Designing Tutorials Creating a Fantastic Fantasy Night Sky in PhotoshopUploaded byhabnam
- Using Graphics Server NET.pdfUploaded byelisa
- Front Sheet KIRAN 2007Uploaded bymarshal robert
- PortfolioUploaded byBen Murphy
- Mike Brooks 3D TV 100203 v2Uploaded byDenny Saputra
- MK GoogleAds FlyerUploaded bycreativemarco
- UnityBloom.txtUploaded byvermisterra
- DIP SyllabusUploaded byvenurao

- June 07 MCS-035Uploaded byVishal Falake
- Line Polygon ClippingUploaded byVishal Falake
- Line AlgorithmsUploaded byKunal
- Java Swing TutorialUploaded byVishal Falake
- IBPS CLERK NOTIFICATION 2013Uploaded byscang55
- Ccna NotesUploaded byRajumallepoola
- Advanced Bash Shell Scripting Guide (Linux)Uploaded bymohammad
- baUploaded bypuby101
- ATM_1Uploaded byDevneet Singh Virdi
- use casesUploaded byVishal Falake
- mcs33Uploaded byVishal Falake
- 11 Basic Shell Programs Enough for IGNOU Exams Observe SyntaxUploaded byVishal Falake
- Complexity Space n TimeUploaded byapi-3814408

- Asmaa ElnawawyUploaded byamrsamak77
- Rate Card BrochureUploaded byDavid Arndt
- Philadelphia Artists‚ Books Travel to Venice: CatalogueUploaded byboxturtlepress
- Visual Creativity A.pdfUploaded byanandanick
- Simultaneous: Seripop & SonnenzimmerUploaded byJulia V. Hendrickson
- graphic design mini-portfolioUploaded byapi-354401399
- Guido CagnacciUploaded byRachel Valladares
- SPD / SCUOLA POLITECNICA DI DESIGNUploaded bygianniverde
- Apple Pay GuidelinesUploaded bydipaby
- Copy of List or Winners MSAP ICE Awards 2015Uploaded byOliver Bayani
- ONYX Quality Evaluation_FAQUploaded byJose Bonillo
- Franz MarcUploaded bySandmansNymphet
- Ink Jet CTP Systems 8.5x11 2015 WEBUploaded byzaryab khan
- Dry media.pdfUploaded byescuipo
- Laser-printer 7 HojasUploaded byRicardo Zevallos Cruz
- Lenticular Education Kit by HumanEyesUploaded byapi-18552290
- books_diyspec_v1_1425935939123.pdfUploaded byServando Asuaje
- Yale NUS College Identity GuidelinesUploaded bycloudman81
- Hidayat Al-Mutallimin Bodl. MSUploaded byNajaf Haider
- photography resume 2Uploaded byapi-410757593
- Advertising AgencyUploaded bysweeto2010
- business card projectUploaded byapi-262218593
- RasterisationUploaded bywaqarakram
- Designing communications for a poster fairUploaded byAbdulkhadir Suhair
- 20 Modern Remakes of Famous Paintings . PIJAMA SURFUploaded byUp Queen
- The Graphic Design Idea Book_ I - Steven Heller.pdfUploaded byreioco
- Branding 101Uploaded byNauman Chaudary
- Good Fun Game 5 Years Chinese Edition 5vrePwscuDkyUploaded bysilver lau
- Art Lesson Plan- WatercolorUploaded byNickolas Walls
- Herman TalvikUploaded byDiana Algus