SlideShare una empresa de Scribd logo
1 de 3
Descargar para leer sin conexión
Outline: Scan conversion
• Scan converting lines: optimising for speed.
• Issues with scan conversion.
• Area primitives.
• How OpenGL does it.
Scan converting lines
• A more advanced algorithm is the midpoint line algorithm.
• Does not use floating point arithmetic.
• Generalisation of Bresenham’s well known incremental technique.
• Works only for 0 ≤ m ≤ 1.
• Other slopes are catered for by reflection about the principal
axes of the 2D plane.
• (x0, y0) is the lower left endpoint and (xe, ye) the upper right
endpoint.
Scan converting lines
• Incremental method:
M
Q
NE
E
Choices
pixel
current
Choice for
pixel
Previous
for next
pixel
• Restrictions on the slope of the line implies that if we are at
some pixel (xp, yp), we now need to choose between only two
pixels.
Scan converting lines
M
Q
NE
E
Choices
pixel
current
Choice for
pixel
Previous
for next
pixel
• Either the east pixel, E, or the northeast pixel, NE, is chosen
depending upon which side of the midpoint, M, the crossing
point, Q, lies.
• Write the implicit functional from: f(x, y) = ax + by + γ = 0.
Scan converting lines
• Noting:
y = mx + c =
∆y
∆x
x + c ,
gives:
f(x, y) = ∆y · x − ∆x · y + ∆x · c .
• Now a = ∆y, b = −∆x and γ = ∆x · c.
• For any point on the line, f(x, y) is zero, any point above the
line, f(x, y) is negative and any point below has f(x, y) positive.
• d = f(M) = f(xp + 1, yp + 1/2) = a(xp + 1) + b(yp + 1/2) + γ.
If d is positive we choose NE, otherwise we pick E (including
when d = 0).
Scan converting lines
• So what happens to the location of the next midpoint, Mnew?
This depends on whether E or NE was chosen. If E is chosen
then the new dnew will be:
dnew = f(Mnew) = f(xp + 2, yp + 1/2)
= a(xp + 2) + b(yp + 1/2) + γ .
• dnew = dold + ∆E, ∆E = a.
Similarly ∆NE = a + b.
• First d = f(x0 + 1, y0 + 1/2) = a(x0 + 1) + b(y0 + 1/2) + γ =
f(x0, y0) + a + b
2, since this on the line d = a + b/2 = ∆y − ∆x/2.
• Using d = 2f(x, y), which will not affect the sign of the decision
variable and keep everything integer.
Scan converting lines
void MidpointLine ( int x0, int xe,
int y0, int ye, int value)
{ /* Assumes 0 <= m <= 1, x0 < xe, y0 < ye */
int x,y,dx,dy,d,incE,incNE;
dx = xe - x0;
dy = ye - y0;
d = 2*dy - dx;
incE = 2*dy;
incNE = 2*(dy-dx);
x = x0;
y = y0;
WritePixel(x,y,value);
while (x < xe) {
if (d <= 0) {
d += incE;
x++;
} else {
d += incNE;
x++;
y++;
}
WritePixel(x,y,value);
}
}
Scan converting lines
• There are several improvements that could be envisaged to the
midpoint algorithm.
• One method involves looking ahead two pixels at a time (so
called double-step algorithm).
• Another uses the symmetry about the midpoint of the whole
line, which allows both ends to be scan converted simultaneously.
• The midpoint algorithm defines that E is chosen when Q = M so
to ensure lines look the same drawn from each end the algorithm
should choose SW rather than W in the inverted version.
Line clipping
NE
y = y_min
x = x_min
M
E
• It is common to clip a line by a bounding rectangle (often the
virtual or real screen boundaries).
• Assume the bounding rectangle has coordinates, (xmin, ymin),
(xmax, ymax).
Line clipping
NE
y = y_min
x = x_min
M
E
• If the line intersects the left hand vertical edge, x = xmin the
intersection point of the line with the boundary is
(xmin, (m · xmin + c)).
• Start the line from (xmin, Round(m · xmin + c)).
Line clipping
x = x_min
y = y_min-0.5
y = y_min
• Assume that any of the lines pixels falling on or inside the clip
region are drawn.
• The line does not start at the point ((ymin − c)/m, ymin) where
the line crosses the bounding line.
• The first pixel is
Round
(ymin − 0.5 − c)
m
, ymin .
Line intensity
• Lines of different slopes will have different intensities on the
display, unless care is taken.
• 2 lines, both 4 pixels but the diagonal one is
√
2 times as long as
the horizontal line.
• Intensity can be set as a function of the line slope.
Scan converting area primitives
void FillRectangle ( int xmin, int xmax,
int ymin, int ymax, int value)
{
int x,y;
for (y = ymin; y <= ymax; y++) {
for (x = xmin; x <= xmax; x++) {
WritePixel(x,y,value);
}
}
}
• Scan converting objects with area is more complex than scan
converting linear objects, due to the boundaries.
A rule that is commonly used to decide what to do with edge
pixels is as follows.
• A boundary pixel is not considered part of the primitive if the
half-plane defined by the edge and containing the primitives lies
below a non-vertical edge or to the left of a vertical edge.
Filling polygons
• Most algorithms work as follows:
– find the intersections of the scan line with all polygon edges;
– sort the intersections;
– fill those points which are interior.
• The first step involves the use of a scan-line algorithm that
takes advantage of edge coherence to produce a data structure
called an active-edge table.
• Edge coherence simply means that if an edge is intersected in
scan line i, it will probably be intersected in scan line i + 1.
Other issues
• Patterns will typically be defined by some form of pixmap
pattern, as in texture mapping.
• In this case the pattern is assumed to fill the entire screen, then
anded with the filled region of the primitive, determining where
the pattern can ‘show through’.
• It is convenient to combine scan conversion with clipping in
integer graphics packages, this being called scissoring.
• Floating point graphics are most efficiently implemented by
performing analytical clipping in the floating point coordinate
system and then scan converting the clipped region.
Scan conversion: OpenGL
• OpenGL performs scan conversion efficiently behind the scenes
– typically using hardware on the graphics card.
• However, we can manipulate pixels using OpenGL with
glRasterPos2i(GLint x, GLint y) and glDrawPixels(·) – in the
labs you will code your own scan conversion routines.
• Speed is often of the essence in computer graphics, so designing
and developing efficient algorithms forms a large part of
computer graphics research.
Anti-aliasing
• All raster primitives outlined so far have a common problem,
that of jaggies : jaggies are a particular instance of aliasing. The
term alias originates from signal processing.
• In the limit, as the pixel size shrinks to an infinitely small dot,
these problems will be minimised, thus one solution is to
increase the screen resolution.
• Doubling screen resolution will quadruple the memory
requirements and the scan conversion time.
Anti-aliasing
• One solution to the problem involves recognising that primitives,
such as lines are really areas in the raster world.
• In unweighted area sampling the intensity of the pixel is set
according to how much of its area is overlapped by the primitive.
• More complex methods involve weighted area sampling.
• Weighted area sampling assumes a realistic model for pixel
intensity. Using a sensible weighting function, such as a cone or
Gaussian function, will result in a smoother anti-aliasing, but at
the price of even greater computational burden.
Anti-aliasing: OpenGL
• Since anti-aliasing is an expensive operation, and may not always
be required OpenGL allows the user to control the level of
anti-aliasing.
• Can be turned on using: glEnable(GL LINE SMOOTH)
• Can also use glHint(GL LINE SMOOTH HINT,GL BEST) to set quality:
GL BEST, GL FASTEST, and GL DONT CARE – hints not always
implemented – based on number of samples.
• Works by using the alpha parameter and colour blending.
Anti-aliasing of polygons treated in the same way in RGBA
mode.
Summary
• Having finished this lecture you should:
– be able to contrast different approaches and sketch their
application;
– provide simple solutions to the problems of clipping and
aliasing;
– understand how scan conversion works in OpenGL.

Más contenido relacionado

La actualidad más candente

Using Generic Image Processing Operations to Detect a Calibration Grid
Using Generic Image Processing Operations to Detect a Calibration GridUsing Generic Image Processing Operations to Detect a Calibration Grid
Using Generic Image Processing Operations to Detect a Calibration GridJan Wedekind
 
Image segmentation
Image segmentationImage segmentation
Image segmentationDeepak Kumar
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphicanku2266
 
Image segmentation
Image segmentationImage segmentation
Image segmentationRania H
 
Edge Detection and Segmentation
Edge Detection and SegmentationEdge Detection and Segmentation
Edge Detection and SegmentationA B Shinde
 
CG OpenGL surface detection+illumination+rendering models-course 9
CG OpenGL surface detection+illumination+rendering models-course 9CG OpenGL surface detection+illumination+rendering models-course 9
CG OpenGL surface detection+illumination+rendering models-course 9fungfung Chen
 
Image representation
Image representationImage representation
Image representationRahul Dadwal
 
Visible surface identification
Visible surface identificationVisible surface identification
Visible surface identificationPooja Dixit
 
Edge Detection algorithm and code
Edge Detection algorithm and codeEdge Detection algorithm and code
Edge Detection algorithm and codeVaddi Manikanta
 
Point Cloud Segmentation for 3D Reconstruction
Point Cloud Segmentation for 3D ReconstructionPoint Cloud Segmentation for 3D Reconstruction
Point Cloud Segmentation for 3D ReconstructionPirouz Nourian
 
Computer vision lane line detection
Computer vision lane line detectionComputer vision lane line detection
Computer vision lane line detectionJonathan Mitchell
 

La actualidad más candente (20)

Using Generic Image Processing Operations to Detect a Calibration Grid
Using Generic Image Processing Operations to Detect a Calibration GridUsing Generic Image Processing Operations to Detect a Calibration Grid
Using Generic Image Processing Operations to Detect a Calibration Grid
 
Edge detection
Edge detectionEdge detection
Edge detection
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Image segmentation
Image segmentation Image segmentation
Image segmentation
 
Line Detection
Line DetectionLine Detection
Line Detection
 
Shading in OpenGL
Shading in OpenGLShading in OpenGL
Shading in OpenGL
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Sr 01-40 good
Sr 01-40 goodSr 01-40 good
Sr 01-40 good
 
Edge Detection and Segmentation
Edge Detection and SegmentationEdge Detection and Segmentation
Edge Detection and Segmentation
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
CG OpenGL surface detection+illumination+rendering models-course 9
CG OpenGL surface detection+illumination+rendering models-course 9CG OpenGL surface detection+illumination+rendering models-course 9
CG OpenGL surface detection+illumination+rendering models-course 9
 
Histogram processing
Histogram processingHistogram processing
Histogram processing
 
Image representation
Image representationImage representation
Image representation
 
Visible surface identification
Visible surface identificationVisible surface identification
Visible surface identification
 
Edge Detection algorithm and code
Edge Detection algorithm and codeEdge Detection algorithm and code
Edge Detection algorithm and code
 
Point Cloud Segmentation for 3D Reconstruction
Point Cloud Segmentation for 3D ReconstructionPoint Cloud Segmentation for 3D Reconstruction
Point Cloud Segmentation for 3D Reconstruction
 
Depth Buffer Method
Depth Buffer MethodDepth Buffer Method
Depth Buffer Method
 
Computer vision lane line detection
Computer vision lane line detectionComputer vision lane line detection
Computer vision lane line detection
 

Similar a Scan Conversion Techniques for Lines and Polygons

Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentationasodariyabhavesh
 
Module-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdfModule-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdfvikasmittal92
 
image segmentation image segmentation.pptx
image segmentation image segmentation.pptximage segmentation image segmentation.pptx
image segmentation image segmentation.pptxNaveenKumar5162
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1aravindangc
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterizationMaaz Rizwan
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterizationMaaz Rizwan
 
The world of loss function
The world of loss functionThe world of loss function
The world of loss function홍배 김
 
Rethinking Attention with Performers
Rethinking Attention with PerformersRethinking Attention with Performers
Rethinking Attention with PerformersJoonhyung Lee
 
Clipping & Rasterization
Clipping & RasterizationClipping & Rasterization
Clipping & RasterizationAhmed Daoud
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fillwahab13
 
Image enhancement
Image enhancementImage enhancement
Image enhancementAyaelshiwi
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphicsShaishavShah8
 
05 contours seg_matching
05 contours seg_matching05 contours seg_matching
05 contours seg_matchingankit_ppt
 
dokumen.tips_scan-conversion-568812b73d987.ppt
dokumen.tips_scan-conversion-568812b73d987.pptdokumen.tips_scan-conversion-568812b73d987.ppt
dokumen.tips_scan-conversion-568812b73d987.pptRishuV1
 

Similar a Scan Conversion Techniques for Lines and Polygons (20)

Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentation
 
Module-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdfModule-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdf
 
Lect14 lines+circles
Lect14 lines+circlesLect14 lines+circles
Lect14 lines+circles
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
 
image segmentation image segmentation.pptx
image segmentation image segmentation.pptximage segmentation image segmentation.pptx
image segmentation image segmentation.pptx
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterization
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterization
 
The world of loss function
The world of loss functionThe world of loss function
The world of loss function
 
Rethinking Attention with Performers
Rethinking Attention with PerformersRethinking Attention with Performers
Rethinking Attention with Performers
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Clipping & Rasterization
Clipping & RasterizationClipping & Rasterization
Clipping & Rasterization
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fill
 
Clipping
ClippingClipping
Clipping
 
CNN_AH.pptx
CNN_AH.pptxCNN_AH.pptx
CNN_AH.pptx
 
CNN_AH.pptx
CNN_AH.pptxCNN_AH.pptx
CNN_AH.pptx
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
05 contours seg_matching
05 contours seg_matching05 contours seg_matching
05 contours seg_matching
 
dokumen.tips_scan-conversion-568812b73d987.ppt
dokumen.tips_scan-conversion-568812b73d987.pptdokumen.tips_scan-conversion-568812b73d987.ppt
dokumen.tips_scan-conversion-568812b73d987.ppt
 

Más de Roziq Bahtiar

Techarea company profile
Techarea company profileTecharea company profile
Techarea company profileRoziq Bahtiar
 
static and dynamic routing
static and dynamic routingstatic and dynamic routing
static and dynamic routingRoziq Bahtiar
 
Perintah perintah dasar linux Operating Sistem
Perintah perintah dasar linux Operating SistemPerintah perintah dasar linux Operating Sistem
Perintah perintah dasar linux Operating SistemRoziq Bahtiar
 
Pengantar algoritma pemrograman
Pengantar algoritma pemrogramanPengantar algoritma pemrograman
Pengantar algoritma pemrogramanRoziq Bahtiar
 
Flowchart progrm linear bilangan bulat
Flowchart progrm linear bilangan bulatFlowchart progrm linear bilangan bulat
Flowchart progrm linear bilangan bulatRoziq Bahtiar
 
Tarby magazine salafiyah kajen
Tarby magazine  salafiyah kajenTarby magazine  salafiyah kajen
Tarby magazine salafiyah kajenRoziq Bahtiar
 
7. pemrograman struktur
7. pemrograman struktur7. pemrograman struktur
7. pemrograman strukturRoziq Bahtiar
 
6. pemrograman pointer
6. pemrograman pointer6. pemrograman pointer
6. pemrograman pointerRoziq Bahtiar
 
5. pemrograman array dan_string
5. pemrograman array dan_string5. pemrograman array dan_string
5. pemrograman array dan_stringRoziq Bahtiar
 
4. pemrograman fungsi
4. pemrograman fungsi4. pemrograman fungsi
4. pemrograman fungsiRoziq Bahtiar
 
3. teknik looping dalam_pemrograman
3. teknik looping dalam_pemrograman3. teknik looping dalam_pemrograman
3. teknik looping dalam_pemrogramanRoziq Bahtiar
 
2. teknik pemilihan dalam_pemrograman
2. teknik pemilihan dalam_pemrograman2. teknik pemilihan dalam_pemrograman
2. teknik pemilihan dalam_pemrogramanRoziq Bahtiar
 
1. variable identifier dan_tipe_data
1. variable identifier dan_tipe_data1. variable identifier dan_tipe_data
1. variable identifier dan_tipe_dataRoziq Bahtiar
 

Más de Roziq Bahtiar (20)

Techarea company profile
Techarea company profileTecharea company profile
Techarea company profile
 
static and dynamic routing
static and dynamic routingstatic and dynamic routing
static and dynamic routing
 
Perintah perintah dasar linux Operating Sistem
Perintah perintah dasar linux Operating SistemPerintah perintah dasar linux Operating Sistem
Perintah perintah dasar linux Operating Sistem
 
Pengantar algoritma pemrograman
Pengantar algoritma pemrogramanPengantar algoritma pemrograman
Pengantar algoritma pemrograman
 
Flowchart progrm linear bilangan bulat
Flowchart progrm linear bilangan bulatFlowchart progrm linear bilangan bulat
Flowchart progrm linear bilangan bulat
 
Tarby magazine salafiyah kajen
Tarby magazine  salafiyah kajenTarby magazine  salafiyah kajen
Tarby magazine salafiyah kajen
 
Pcd 10
Pcd 10Pcd 10
Pcd 10
 
Pcd 11
Pcd 11Pcd 11
Pcd 11
 
7. pemrograman struktur
7. pemrograman struktur7. pemrograman struktur
7. pemrograman struktur
 
6. pemrograman pointer
6. pemrograman pointer6. pemrograman pointer
6. pemrograman pointer
 
5. pemrograman array dan_string
5. pemrograman array dan_string5. pemrograman array dan_string
5. pemrograman array dan_string
 
4. pemrograman fungsi
4. pemrograman fungsi4. pemrograman fungsi
4. pemrograman fungsi
 
3. teknik looping dalam_pemrograman
3. teknik looping dalam_pemrograman3. teknik looping dalam_pemrograman
3. teknik looping dalam_pemrograman
 
2. teknik pemilihan dalam_pemrograman
2. teknik pemilihan dalam_pemrograman2. teknik pemilihan dalam_pemrograman
2. teknik pemilihan dalam_pemrograman
 
1. variable identifier dan_tipe_data
1. variable identifier dan_tipe_data1. variable identifier dan_tipe_data
1. variable identifier dan_tipe_data
 
Alpro tutor
Alpro tutorAlpro tutor
Alpro tutor
 
Pcd 7
Pcd 7Pcd 7
Pcd 7
 
Pcd 5
Pcd 5Pcd 5
Pcd 5
 
Pcd 4
Pcd 4Pcd 4
Pcd 4
 
Eigen
EigenEigen
Eigen
 

Último

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 

Último (20)

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 

Scan Conversion Techniques for Lines and Polygons

  • 1. Outline: Scan conversion • Scan converting lines: optimising for speed. • Issues with scan conversion. • Area primitives. • How OpenGL does it. Scan converting lines • A more advanced algorithm is the midpoint line algorithm. • Does not use floating point arithmetic. • Generalisation of Bresenham’s well known incremental technique. • Works only for 0 ≤ m ≤ 1. • Other slopes are catered for by reflection about the principal axes of the 2D plane. • (x0, y0) is the lower left endpoint and (xe, ye) the upper right endpoint. Scan converting lines • Incremental method: M Q NE E Choices pixel current Choice for pixel Previous for next pixel • Restrictions on the slope of the line implies that if we are at some pixel (xp, yp), we now need to choose between only two pixels. Scan converting lines M Q NE E Choices pixel current Choice for pixel Previous for next pixel • Either the east pixel, E, or the northeast pixel, NE, is chosen depending upon which side of the midpoint, M, the crossing point, Q, lies. • Write the implicit functional from: f(x, y) = ax + by + γ = 0. Scan converting lines • Noting: y = mx + c = ∆y ∆x x + c , gives: f(x, y) = ∆y · x − ∆x · y + ∆x · c . • Now a = ∆y, b = −∆x and γ = ∆x · c. • For any point on the line, f(x, y) is zero, any point above the line, f(x, y) is negative and any point below has f(x, y) positive. • d = f(M) = f(xp + 1, yp + 1/2) = a(xp + 1) + b(yp + 1/2) + γ. If d is positive we choose NE, otherwise we pick E (including when d = 0). Scan converting lines • So what happens to the location of the next midpoint, Mnew? This depends on whether E or NE was chosen. If E is chosen then the new dnew will be: dnew = f(Mnew) = f(xp + 2, yp + 1/2) = a(xp + 2) + b(yp + 1/2) + γ . • dnew = dold + ∆E, ∆E = a. Similarly ∆NE = a + b. • First d = f(x0 + 1, y0 + 1/2) = a(x0 + 1) + b(y0 + 1/2) + γ = f(x0, y0) + a + b 2, since this on the line d = a + b/2 = ∆y − ∆x/2. • Using d = 2f(x, y), which will not affect the sign of the decision variable and keep everything integer. Scan converting lines void MidpointLine ( int x0, int xe, int y0, int ye, int value) { /* Assumes 0 <= m <= 1, x0 < xe, y0 < ye */ int x,y,dx,dy,d,incE,incNE; dx = xe - x0; dy = ye - y0; d = 2*dy - dx; incE = 2*dy; incNE = 2*(dy-dx); x = x0; y = y0; WritePixel(x,y,value); while (x < xe) { if (d <= 0) { d += incE; x++; } else { d += incNE; x++; y++; } WritePixel(x,y,value); } } Scan converting lines • There are several improvements that could be envisaged to the midpoint algorithm. • One method involves looking ahead two pixels at a time (so called double-step algorithm). • Another uses the symmetry about the midpoint of the whole line, which allows both ends to be scan converted simultaneously. • The midpoint algorithm defines that E is chosen when Q = M so to ensure lines look the same drawn from each end the algorithm should choose SW rather than W in the inverted version.
  • 2. Line clipping NE y = y_min x = x_min M E • It is common to clip a line by a bounding rectangle (often the virtual or real screen boundaries). • Assume the bounding rectangle has coordinates, (xmin, ymin), (xmax, ymax). Line clipping NE y = y_min x = x_min M E • If the line intersects the left hand vertical edge, x = xmin the intersection point of the line with the boundary is (xmin, (m · xmin + c)). • Start the line from (xmin, Round(m · xmin + c)). Line clipping x = x_min y = y_min-0.5 y = y_min • Assume that any of the lines pixels falling on or inside the clip region are drawn. • The line does not start at the point ((ymin − c)/m, ymin) where the line crosses the bounding line. • The first pixel is Round (ymin − 0.5 − c) m , ymin . Line intensity • Lines of different slopes will have different intensities on the display, unless care is taken. • 2 lines, both 4 pixels but the diagonal one is √ 2 times as long as the horizontal line. • Intensity can be set as a function of the line slope. Scan converting area primitives void FillRectangle ( int xmin, int xmax, int ymin, int ymax, int value) { int x,y; for (y = ymin; y <= ymax; y++) { for (x = xmin; x <= xmax; x++) { WritePixel(x,y,value); } } } • Scan converting objects with area is more complex than scan converting linear objects, due to the boundaries. A rule that is commonly used to decide what to do with edge pixels is as follows. • A boundary pixel is not considered part of the primitive if the half-plane defined by the edge and containing the primitives lies below a non-vertical edge or to the left of a vertical edge. Filling polygons • Most algorithms work as follows: – find the intersections of the scan line with all polygon edges; – sort the intersections; – fill those points which are interior. • The first step involves the use of a scan-line algorithm that takes advantage of edge coherence to produce a data structure called an active-edge table. • Edge coherence simply means that if an edge is intersected in scan line i, it will probably be intersected in scan line i + 1. Other issues • Patterns will typically be defined by some form of pixmap pattern, as in texture mapping. • In this case the pattern is assumed to fill the entire screen, then anded with the filled region of the primitive, determining where the pattern can ‘show through’. • It is convenient to combine scan conversion with clipping in integer graphics packages, this being called scissoring. • Floating point graphics are most efficiently implemented by performing analytical clipping in the floating point coordinate system and then scan converting the clipped region. Scan conversion: OpenGL • OpenGL performs scan conversion efficiently behind the scenes – typically using hardware on the graphics card. • However, we can manipulate pixels using OpenGL with glRasterPos2i(GLint x, GLint y) and glDrawPixels(·) – in the labs you will code your own scan conversion routines. • Speed is often of the essence in computer graphics, so designing and developing efficient algorithms forms a large part of computer graphics research.
  • 3. Anti-aliasing • All raster primitives outlined so far have a common problem, that of jaggies : jaggies are a particular instance of aliasing. The term alias originates from signal processing. • In the limit, as the pixel size shrinks to an infinitely small dot, these problems will be minimised, thus one solution is to increase the screen resolution. • Doubling screen resolution will quadruple the memory requirements and the scan conversion time. Anti-aliasing • One solution to the problem involves recognising that primitives, such as lines are really areas in the raster world. • In unweighted area sampling the intensity of the pixel is set according to how much of its area is overlapped by the primitive. • More complex methods involve weighted area sampling. • Weighted area sampling assumes a realistic model for pixel intensity. Using a sensible weighting function, such as a cone or Gaussian function, will result in a smoother anti-aliasing, but at the price of even greater computational burden. Anti-aliasing: OpenGL • Since anti-aliasing is an expensive operation, and may not always be required OpenGL allows the user to control the level of anti-aliasing. • Can be turned on using: glEnable(GL LINE SMOOTH) • Can also use glHint(GL LINE SMOOTH HINT,GL BEST) to set quality: GL BEST, GL FASTEST, and GL DONT CARE – hints not always implemented – based on number of samples. • Works by using the alpha parameter and colour blending. Anti-aliasing of polygons treated in the same way in RGBA mode. Summary • Having finished this lecture you should: – be able to contrast different approaches and sketch their application; – provide simple solutions to the problems of clipping and aliasing; – understand how scan conversion works in OpenGL.