Raster graphics & Line Drawing Algorithms Kaushik.S VIT

Slides:



Advertisements
Similar presentations
Line Drawing Algorithms
Advertisements

2.01 Investigate graphic image design. Image Resolution.
Introduction to Computer Graphics Raster Vs. Vector COMMUNICATION TECHNOLOGY.
Computer Graphics- SCC 342
Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
Advanced Manufacturing Laboratory Department of Industrial Engineering Sharif University of Technology Session # 6.
OUTPUT PRIMITIVES Screen vs. World coordinate systems ● Objects positions are specified in a Cartesian coordinate system called World Coordinate.
L.Ghadah R. Hadba CT1514-L1.  Computer Graphics :refers to processing of creating a new image from Geometry, Lighting parameters, Materials and Textures.Using.
Introduction to Illustrator. With the release of Illustrator, Adobe has completed a tightly integrated trio of applications (Photoshop, InDesign and now.
Objectives Define photo editing software
Output Primitives Computer Graphics.
Multimedia for the Web: Creating Digital Excitement Multimedia Element -- Graphics.
Course Website: Computer Graphics 5: Line Drawing Algorithms.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphicsIntroduction Dr. Eng. Farag Elnagahy
Introduction to Computer Graphics
1.Introduction to Computer Graphics GMR lab. What is computer garphics? The generation of graphical output using a computer Refers to creation, Storage.
Vector vs. Bitmap SciVis V
Monitors and Sound Systems section 3A This lesson includes the following sections: · Monitors · PC Projectors · Sound Systems.
Objective 1.  Also known as raster images.  Made up of pixels in a grid.  Pixels: tiny dots of individual color that makes up what you see on your.
V Obtained from a summer workshop in Guildford County July, 2014
Digital Images. Scanned or digitally captured image Image created on computer using graphics software.
Bitmapped Images. Bitmap Images Today’s Objectives Identify characteristics of bitmap images Resolution, bit depth, color mode, pixels Determine the most.
IE433 CAD/CAM Computer Aided Design and Computer Aided Manufacturing Part-2 CAD Systems Industrial Engineering Department King Saud University.
COMP Bitmapped and Vector Graphics Pages Using Qwizdom.
1 In the name of God Computer Graphics. 2 Image Mathematical Model Image Analysis (pattern recognition) Image Synthesis (Rendering) ModelingImage processing.
Dr. S.M. Malaek Assistant: M. Younesi
1 CPE 333 : Computer Graphics มหาวิทยาลัยเทคโนโลยีพระจอม เกล้าธนบุรี Dr. Natasha Dejdumrong.
Digital Terminology. Bitmap A representation consisting of rows and columns of dots of a graphic image stored in computer memory. To display a bitmap.
JRN 302: Introduction to Graphics and Visual Communication - Raster and Vector Files Tuesday, 9/8/15.
Vector vs. Bitmap
Objectives Differentiate between raster scan display and random scan display.
2.01D Investigate graphic image design. Image Resolution.
CGMB214: Introduction to Computer Graphics
Graphics. Graphic is the important media used to show the appearance of integrative media applications. According to DBP dictionary, graphics mean drawing.
 A line segment in a scene is defined by the coordinate positions of the line end-points x y (2, 2) (7, 5)
INT 840E Computer graphics Introduction & Graphic’s Architecture.
Introduction to Graphical Hardware Display Technologies
Illustrator I I450 Technology Seminar. Bitmap vs. Vector Photoshop = Bitmap Illustrator = Vector Bitmap images are resolution dependent Vector images.
Lecture 7: Intro to Computer Graphics. Remember…… DIGITAL - Digital means discrete. DIGITAL - Digital means discrete. Digital representation is comprised.
Adobe Photoshop CS5 – Illustrated Unit A: Getting Started with Photoshop CS5.
Data Representation The storage of Text Numbers Graphics.
Beam Penetration & Shadow Mask Method
Computer Fundamentals MSCH 233 Lecture 5. The Monitor A Monitor is a video screen that looks like a TV. It displays both the input data and instructions,
1 CSCE 441 Lecture 2: Scan Conversion of Lines Jinxiang Chai.
GEOMETRY AND LINE GENERATION Geometry and Line Generation Chapter 2.
Lecture 13: Raster Graphics and Scan Conversion
Adobe Photoshop CS4 – Illustrated Unit A: Getting Started with Photoshop CS4.
Guilford County SciVis V104.03
OUTPUT PRIMITIVES A.Aruna/Faculty of Information technology/SNSCE13/19/2016.
Lecture 2: 19/4/1435 Graphical algorithms Lecturer/ Kawther Abas CS- 375 Graphics and Human Computer Interaction.
1.  The primary output device in a graphics system is a video monitor. These monitors are based on Cathode Ray Tube (CRT) design.  CRT is a vacuum tube/electron.
Computer Graphics CC416 Lecture 02: Overview of Graphics Systems: Raster & Random Displays – Chapter 2 Dr. Manal Helal – Fall 2014.
Photoshop CS6 – Nelson Unit 3: Photoshop CS6. Objectives Define photo editing software Start Photoshop and view the workspace Use the Zoom tool and the.
Computer Graphics : output primitives.. 2 of 32 T1 – pp. 103–123, 137–145, 147–150, 164–171 Points and LinesPoints Line Drawing AlgorithmsLine Mid–Point.
Line Drawing Algorithms 1. A line in Computer graphics is a portion of straight line that extends indefinitely in opposite direction. 2. It is defined.
Vector vs. Bitmap. Vector Images Vector images (also called outline images) are images made with lines, text, and shapes. Test type is considered to be.
Computer Graphics Lecture 4 Computer Graphics Hardware
Line Drawing Algorithms
Getting Started with Adobe Photoshop CS6
Computer Graphics Lecture 3 Computer Graphics Hardware
Binary Notation and Intro to Computer Graphics
Vector vs. Bitmap.
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Overview of Graphics Systems
Computer Graphics 5: Line Drawing Algorithms
Computer Graphics 5: Line Drawing Algorithms
Graphics Systems SUBJECT: COMPUTER GRAPHICS LECTURE NO: 02 BATCH: 16BS(INFORMATION TECHNOLOGY) 1/4/
Computer Graphics 5: Line Drawing Algorithms
Graphics Systems Lecture-2
Chapter 2 Overview of Graphics Systems
Presentation transcript:

Raster graphics & Line Drawing Algorithms Kaushik.S VIT

“Raster” The word "raster" has its origins in the Latin rastrum (a rake), which is derived from radere (to scrape), and was originally used in the raster scan of cathode ray tubes (CRT), which paint the image line by line; it is used for a grid of pixels by generalization.

Raster graphics- An Introduction In computer graphics, a raster graphics image or bitmap is a data structure representing a generally rectangular grid of pixels, or points of color, viewable via a monitor, paper, or other display medium. Raster images are stored in image files with varying formats.

Bitmap A bitmap corresponds bit-for-bit with an image displayed on a screen, generally in the same format used for storage in the display's video memory, or maybe as a device-independent bitmap. A bitmap is technically characterized by the width and height of the image in pixels and by the number of bits per pixel (a color depth, which determines the number of colors it can represent).

Imagine the smiley face in the top left corner as an RGB bitmap image Imagine the smiley face in the top left corner as an RGB bitmap image. When enlarged, it might look like the big smiley face to the right. Every square represents a pixel. Zooming in further, the individual pixels can be analyzed, with their colors constructed by adding the values for red, green and blue.

Resolution Raster graphics are resolution dependent. They cannot scale up to an arbitrary resolution without loss of apparent quality. This property contrasts with the capabilities of vector graphics, which easily scale up to the quality of the device rendering them. Raster graphics deal more practically than vector graphics with photographs and photo-realistic images, while vector graphics often serve better for typesetting or for graphic design.

Modern computer-monitors typically display about 72 to 130 pixels per inch (PPI), and some modern consumer printers can resolve 2400 dots per inch (DPI) or more; Typically, a resolution of 150 to 300 pixel per inch works well for 4-color process (CMYK) printing.

Raster-based image editors Raster-based image editors, such as Photoshop, MS Paint, and GIMP, revolve around editing pixels, unlike vector-based image editors, such as CorelDRAW, Adobe Illustrator, or Inkscape, which revolve around editing lines and shapes (vectors).

Raster-based image editors When an image is rendered in a raster-based image editor, the image is composed of millions of pixels. At its core, a raster image editor works by manipulating each individual pixel. Most pixel-based image editors work using the RGB color model, but some also allow the use of other color models such as the CMYK color model.

File formats Bitmap A bitmap or pixmap is pixel data storage structure employed by the majority of raster graphics file formats such as PNG. OpenRaster OpenRaster is a file format being developed under the auspices of the Create Project to give free software graphics editors a common raster graphics interchange format, that maintains as much of the working information that the applications use. .ico ICO file format is an image file format for icons in Microsoft Windows. .ico files contain one or more small images at multiple sizes and color depths.

Programming in the Simple Raster Graphics Package (SRGP) Cartesian coordinates A coordinate system base on two perpendicular axes, with positive coordinates to the right of the origin and above the origin. OR mode A graphic write mode in which each pixel bit becomes 1 if the current display bit is 1 or if the bit being written is 1. arc A section of an ellipse. canvas An area of memory which is used as a buffer between graphics software and graphics hardware. clipping The restriction of rendering to a designated area.

SRGP (cont…) exclusive or mode A graphic write mode in which each pixel bit becomes 1 only if the current display bit and the bit being written are different. font A set of character glyphs, usually consistent line A one dimensional geometric figure defined by two points. point A geometric figure with location only. replace mode A graphic write mode which is not affected by the previous contents of the display. screen coordinates A coordinate system based on the pixels of the PC BIOS, with the origin being at the upper left of the screen, and pixel rows being numbered downward.

Graphics Hardware It’s worth taking a little look at how graphics hardware works before we go any further How do things end up on the screen? Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

Architecture Of A Graphics System Display Processor Memory Frame Buffer Video Controller Monitor Monitor CPU Display Processor System Memory System Bus

Output Devices There are a range of output devices currently available: Printers/plotters Cathode ray tube displays Plasma displays LCD displays 3 dimensional viewers Virtual/augmented reality headsets We will look briefly at some of the more common display devices

Basic Cathode Ray Tube (CRT) Fire an electron beam at a phosphor coated screen Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

Raster Scan Systems Draw one line at a time Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

Colour CRT An electron gun for each colour – red, green and blue Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

Plasma-Panel Displays Applying voltages to crossing pairs of conductors causes the gas (usually a mixture including neon) to break down into a glowing plasma of electrons and ions Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

Liquid Crystal Displays Light passing through the liquid crystal is twisted so it gets through the polarizer A voltage is applied using the crisscrossing conductors to stop the twisting and turn pixels off Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

2D Line Drawing Algorithm: The Problem Of Scan Conversion A line segment in a scene is defined by the coordinate positions of the line end-points x y (7, 5) (2, 2)

The Problem (cont…) But what happens when we try to draw this on a pixel based display? How do we choose which pixels to turn on?

Considerations Considerations to keep in mind: The line has to look good Avoid jaggies It has to be lightening fast! How many lines need to be drawn in a typical scene? This is going to come back to bite us again and again

Line Equations Let’s quickly review the equations involved in drawing lines Slope-intercept line equation: x y y0 yend xend x0 where:

Lines & Slopes The slope of a line (m) is defined by its start and end coordinates The diagram below shows some examples of lines and their slopes m = 0 m = -1/3 m = -1/2 m = -1 m = -2 m = -4 m = ∞ m = 1/3 m = 1/2 m = 1 m = 2 m = 4

A Very Simple Solution We could simply work out the corresponding y coordinate for each unit x coordinate Let’s consider the following example: x y (2, 2) (7, 5) 2 7 5

A Very Simple Solution (cont…) 5 4 3 2 1 1 2 3 4 5 6 7

A Very Simple Solution (cont…) x y (2, 2) (7, 5) 2 3 4 5 6 7 First work out m and b: Now for each x value work out the y value:

A Very Simple Solution (cont…) Now just round off the results and turn on these pixels to draw our line 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8

A Very Simple Solution (cont…) However, this approach is just way too slow In particular look out for: The equation y = mx + b requires the multiplication of m by x Rounding off the resulting y coordinates We need a faster solution

A Quick Note About Slopes In the previous example we chose to solve the parametric line equation to give us the y coordinate for each unit x coordinate What if we had done it the other way around? So this gives us: where: and

A Quick Note About Slopes (cont…) Leaving out the details this gives us: We can see easily that this line doesn’t look very good! We choose which way to work out the line pixels based on the slope of the line 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8

A Quick Note About Slopes (cont…) If the slope of a line is between -1 and 1 then we work out the y coordinates for a line based on it’s unit x coordinates Otherwise we do the opposite – x coordinates are computed based on unit y coordinates m = 0 m = -1/3 m = -1/2 m = -1 m = -2 m = -4 m = ∞ m = 1/3 m = 1/2 m = 1 m = 2 m = 4

A Quick Note About Slopes (cont…) 5 4 3 2 1 1 2 3 4 5 6 7

The DDA Algorithm The digital differential analyzer (DDA) algorithm takes an incremental approach in order to speed up scan conversion Simply calculate yk+1 based on yk The original differential analyzer was a physical machine developed by Vannevar Bush at MIT in the 1930’s in order to solve ordinary differential equations. .

The DDA Algorithm (cont…) Consider the list of points that we determined for the line in our previous example: (2, 2), (3, 23/5), (4, 31/5), (5, 34/5), (6, 42/5), (7, 5) Notice that as the x coordinates go up by one, the y coordinates simply go up by the slope of the line This is the key insight in the DDA algorithm

The DDA Algorithm (cont…) When the slope of the line is between -1 and 1 begin at the first point in the line and, by incrementing the x coordinate by 1, calculate the corresponding y coordinates as follows: When the slope is outside these limits, increment the y coordinate by 1 and calculate the corresponding x coordinates as follows:

The DDA Algorithm (cont…) Again the values calculated by the equations used by the DDA algorithm must be rounded to match pixel values (xk+1, round(yk+m)) (round(xk+ 1/m), yk+1) (xk, yk) (xk+ 1/m, yk+1) (xk+1, yk+m) (xk, yk) (round(xk), yk) (xk, round(yk))

DDA Algorithm Example Let’s try out the following examples: x y (2, 2) (7, 5) 2 7 5 x y (2, 7) (3, 2) 2 3 7

DDA Algorithm Example (cont…) 7 6 5 4 3 2 1 2 3 4 5 6 7

The DDA Algorithm Summary The DDA algorithm is much faster than our previous attempt In particular, there are no longer any multiplications involved However, there are still two big issues: Accumulation of round-off errors can make the pixelated line drift away from what was intended The rounding operations and floating point arithmetic involved are time consuming

Any Doubts???