SlideShare a Scribd company logo
1 of 25
Scan Conversion
A. Samal
Scan Conversion
• Last step in the graphics pipeline
• Efficiency is a central issue
• Common primitives
– Lines
– Polygons
– Circles
• Hardware implementations preferable
Lines
• Compute the coordinate of the pixels that lie on a
line on a 2D raster
• Defined by the coordinates of the end points
• Criteria
– Thin
– As close to ideal as possible
– 1 pixel wide
• If -1<= slope <= 1 exactly 1 pixel in one column
• Else exactly 1 pixel in one row
– Constant brightness, independent of the length &
orientation
– Should be drawn fast
Scan Conversion of Lines
Basic Incremental Algorithm
b
mx
y
line
a
of
Equation 

:
0
1
0
1
x
x
y
y
x
y
m






1
1 

 m
Assume
y
than
faster
increases
x
So,
)
, 0
y
(x
:
point
Starting 0
)
, 1
1 y
(x
:
point
Ending
Problem
• for each x plot pixel at closest y
–Problems for steep lines
Basic Incremental Algorithm
)
y
,round
(x i
i )
(
)
,y
(x i
i
m)
,y
(x i
i 
1
)
m
y
,round
(x i
i )
(
1 

Desired Line
Basic Incremental Algorithm
• Brute force algorithm
• Inefficient
• Each iteration
– Floating point multiply
– Floating point addition
– Rounding
{
)
,
,
,
( 1
1 y
x
y
x
Line 0
0
;
1
1
0
0
x
x
y
y
m



){
;
; 1 


 i
i
0
i x
x
x
x
for(x
);
( b
mx
Round
y i
i 

}
}
);
,
( i
i y
x
drawpixel
Basic Incremental Algorithm
• Eliminate the
multiplication
• Incremental
computation
• Digital Differential
Analyzer (DDA)
b
mx
y i
i 
 
 1
1
}
}
;
));
(
,
(
){
;
;
;
;
{
);
,
,
,
(
1
1
1
1
1
m
y
y
y
Round
x
drawpixel
x
x
x
x
for(x
y
y
x
x
y
y
m
y
x
y
x
Line
i
i
i
i
i
i
0
i
0
i
0
0
0
0










m
y
y
then
x
If i
i 


 1
1
b
x
x
m i 


 )
(
x
m
yi 


b
mx
y i
i 

Basic Incremental Algorithm
• If the magnitude of the slope is more than 1 change
the role of x and y in the algorithm
– y increases faster than x
• Simple but inefficient
– Still there are floating point operations
• Bresenham’s algorithm
– Uses only integer arithmetic
– Avoids round function
– Extended to drawing circles
Midpoint Line Algorithm
1
1 

 m
Assume
(NE)
NorthEast
(E)
East
choices
Two :
right
upper
:
y
x
left
lower
:
y
x
)
,
(
)
,
(
1
1
0
0
)
,
(
: p
p y
x
pixel
Previous
next?
be
should
pixel
Which
E
NE
M
Previous
Pixel
Current Pixel
Choices
Next Pixel
Choices
)
,
( p
p y
x
P 
Q
Midpoint Line Algorithm
y
x
pixel
Previous p
p )
,
(
:
• Compute the distance between
– Q and E
– Q and NE
• See which side of the line M lies
• M lies below the line
– Choose NE
• M lies above the line
– Choose E
• M lies on the line
– Choose either
1

 p
x
x
with
line
the
of
on
intersecti
of
Point
:
Q
E
NE
M
Previous
Pixel
Current Pixel
Choices
Next Pixe
Choices
)
,
( p
p y
x
P 
Q
Midpoint Line Algorithm
lies?
point
a
line
the
of
side
which
know
we
do
How
)
.(
);
(
);
( 0
1
0
1
0
1 x
x
B
c
x
x
dx
b
y
y
dy
a 









line
the
of
tion
Representa
Implicit
0
c
by
ax
y)
F(x, 



line
the
of
tion
Representa
Explicit
B
x
dx
dy
B
mx
y 



0
.
.
. 

 dx
B
y
dx
x
dy
Midpoint Line Algorithm
lies?
point
a
line
the
of
side
which
know
we
do
How
)
2
1
,
1
(
) 

 p
p x
x
F
F(M
of
sign
the
Check








line
the
below
points
for
line
the
above
points
for
line
the
on
points
for
y
x
F
0
0
0
)
,
(
line
the
below
or
above
lies
Q
if
test
To
Midpoint Line Algorithm
d
variable
decison
a
Define
NE
or
E
Choose
d 
 0
)
2
1
,
1 

 p
p y
F(x
d
E
Choose
Q)
M
d

 above
is
(
0
NE
Choose
Q)
below
is
(M
d

 0
E
NE
M
Previous
Pixel
Current Pixel
Choices
Next Pixel
Choices
)
,
( p
p y
x
P 
Q
Midpoint Line Algorithm
value
the
in
change
the
on
based
Add
directly
F(M)
of
value
the
compute
not
Do

• What happens at the next grid point?
– Depends on whether we choose N or NE
• If E is chosen
c
y
b
x
a
y
x
F
d p
p
p
p
new 






 )
2
1
(
)
2
(
)
2
1
,
2
(
c
y
b
x
a
d p
p
old 



 )
2
1
(
)
1
(
a
d
d old
new 
 dy
a
d
d old
new
E 




E)
choose
we
after
d
in
increment
E (
 E
N
E
M
Previo
us
Pixel
Current
Pixel
Choices
Next Pixel
Choices
)
,
( p
p y
x
P 
Q
Midpoint Line Algorithm
• If NE is chosen
c
y
b
x
a
y
x
F
d p
p
p
p
new 






 )
2
3
(
)
2
(
)
2
3
,
2
(
NE)
choose
we
after
d
in
increment
NE (

c
y
b
x
a
d p
p
old 



 )
2
1
(
)
1
(
b
a
d
d old
new 


dx
dy
b
a
d
d old
new
NE 






value
the
in
change
the
on
based
Add
directly
F(M)
of
value
the
compute
not
Do

E
N
E
M
Previo
us
Pixel
Current
Pixel
Choices
Next Pixel
Choices
)
,
( p
p y
x
P 
Q
Midpoint Line Algorithm
• Summary
– Choose between the two pixels (E/NE) based on
the sign of the decision variable d=F(M)
– Update the decision variable by adding the change
along that direction
– Repeat this process until the end point is reached
Midpoint Line Algorithm
2
dx
dy 

d
variable
decision
the
for
value
Initial
)
2
1
,
1 


 0
0
start y
F(x
F(M)
d
c
y
b
x
a 0
0 



 )
2
1
(
)
1
(
2
b
a
c
by
ax 0
0 




line
the
on
lies
)
,y
(x
since
b
a 0
0
2


Midpoint Line Algorithm
• Fractional arithmetic still problematic
• Should be avoided if possible
• Redefine F(x,y) by multiplying by 2
• Thus F(x,y) = 2(ax+by+c)
• Replace all constants and the decision variable
by 2
• Removes all multiplications; only additions left
Midpoint Line Algorithm
c)
by
(ax
F(x,y) 

 2
dx
dy
b
a
dstart 


 2
2
)
(
*
2 dx
dy
NE 


dy
E .
2


Midpoint Line Algorithm
MidpointLine(x0,y0,x1,y1,color)
{
int dx,dy,dE,dNE,d,x,y;
dx=x1-x0; dy=y1-y0;
d=2*dy-dx;
dE=2*dy; dNE=2*(dy-dx);
x=x0;y=y0;
DrawPixel(x,y,color);
for(x=x0;x<x1; x++) {
if (d<=0) d+=dE ;
else {d+=dNE; y++;}
DrawPixel(x,y,color);
}
Bresenham’s Algorithm
An example
4 5 6 7 8 9
7
8
9
10
11
12
(x0 , y0 )  (5,8)
(x4 , y4 )  (9,11)
x  4
y  3
incrE  2y  6
incrNE  2(y  x)  2
d0
 2y  x  2
 first choice is NE
Bresenham’s Algorithm
An example
4 5 6 7 8 9
7
8
9
10
11
12
d1  d0  incrNE  2  2  0
second choice is E
Bresenham’s Algorithm
An example
4 5 6 7 8 9
7
8
9
10
11
12
d2  d1  incrE  0  6  6
third choice is NE

More Related Content

Similar to dokumen.tips_scan-conversion-568812b73d987.ppt

Open GL T0074 56 sm3
Open GL T0074 56 sm3Open GL T0074 56 sm3
Open GL T0074 56 sm3Roziq Bahtiar
 
Unit 2
Unit 2Unit 2
Unit 2ypnrao
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimediasaranyan75
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivessaranyan75
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1aravindangc
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4Roziq Bahtiar
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithmsMohammad Sadiq
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesAnkit Garg
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2SanthiNivas
 
Lab lecture 1 line_algo
Lab lecture 1 line_algoLab lecture 1 line_algo
Lab lecture 1 line_algosimpleok
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygonsaa11bb11
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons dericationKumar
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniyaTutorialsDuniya.com
 
Lecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.pptLecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.pptGaganvirKaur
 

Similar to dokumen.tips_scan-conversion-568812b73d987.ppt (20)

03.Scan Conversion.ppt
03.Scan Conversion.ppt03.Scan Conversion.ppt
03.Scan Conversion.ppt
 
Open GL T0074 56 sm3
Open GL T0074 56 sm3Open GL T0074 56 sm3
Open GL T0074 56 sm3
 
Unit 2
Unit 2Unit 2
Unit 2
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimedia
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitives
 
Computer graphics notes watermark
Computer graphics notes watermarkComputer graphics notes watermark
Computer graphics notes watermark
 
CG-Lecture3.pptx
CG-Lecture3.pptxCG-Lecture3.pptx
CG-Lecture3.pptx
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithms
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
Lab lecture 1 line_algo
Lab lecture 1 line_algoLab lecture 1 line_algo
Lab lecture 1 line_algo
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygons
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons derication
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniya
 
Lecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.pptLecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.ppt
 

Recently uploaded

(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 

Recently uploaded (20)

(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 

dokumen.tips_scan-conversion-568812b73d987.ppt

  • 2. Scan Conversion • Last step in the graphics pipeline • Efficiency is a central issue • Common primitives – Lines – Polygons – Circles • Hardware implementations preferable
  • 3. Lines • Compute the coordinate of the pixels that lie on a line on a 2D raster • Defined by the coordinates of the end points • Criteria – Thin – As close to ideal as possible – 1 pixel wide • If -1<= slope <= 1 exactly 1 pixel in one column • Else exactly 1 pixel in one row – Constant brightness, independent of the length & orientation – Should be drawn fast
  • 5. Basic Incremental Algorithm b mx y line a of Equation   : 0 1 0 1 x x y y x y m       1 1    m Assume y than faster increases x So, ) , 0 y (x : point Starting 0 ) , 1 1 y (x : point Ending
  • 6. Problem • for each x plot pixel at closest y –Problems for steep lines
  • 7. Basic Incremental Algorithm ) y ,round (x i i ) ( ) ,y (x i i m) ,y (x i i  1 ) m y ,round (x i i ) ( 1   Desired Line
  • 8. Basic Incremental Algorithm • Brute force algorithm • Inefficient • Each iteration – Floating point multiply – Floating point addition – Rounding { ) , , , ( 1 1 y x y x Line 0 0 ; 1 1 0 0 x x y y m    ){ ; ; 1     i i 0 i x x x x for(x ); ( b mx Round y i i   } } ); , ( i i y x drawpixel
  • 9. Basic Incremental Algorithm • Eliminate the multiplication • Incremental computation • Digital Differential Analyzer (DDA) b mx y i i     1 1 } } ; )); ( , ( ){ ; ; ; ; { ); , , , ( 1 1 1 1 1 m y y y Round x drawpixel x x x x for(x y y x x y y m y x y x Line i i i i i i 0 i 0 i 0 0 0 0           m y y then x If i i     1 1 b x x m i     ) ( x m yi    b mx y i i  
  • 10. Basic Incremental Algorithm • If the magnitude of the slope is more than 1 change the role of x and y in the algorithm – y increases faster than x • Simple but inefficient – Still there are floating point operations • Bresenham’s algorithm – Uses only integer arithmetic – Avoids round function – Extended to drawing circles
  • 11. Midpoint Line Algorithm 1 1    m Assume (NE) NorthEast (E) East choices Two : right upper : y x left lower : y x ) , ( ) , ( 1 1 0 0 ) , ( : p p y x pixel Previous next? be should pixel Which E NE M Previous Pixel Current Pixel Choices Next Pixel Choices ) , ( p p y x P  Q
  • 12. Midpoint Line Algorithm y x pixel Previous p p ) , ( : • Compute the distance between – Q and E – Q and NE • See which side of the line M lies • M lies below the line – Choose NE • M lies above the line – Choose E • M lies on the line – Choose either 1   p x x with line the of on intersecti of Point : Q E NE M Previous Pixel Current Pixel Choices Next Pixe Choices ) , ( p p y x P  Q
  • 13. Midpoint Line Algorithm lies? point a line the of side which know we do How ) .( ); ( ); ( 0 1 0 1 0 1 x x B c x x dx b y y dy a           line the of tion Representa Implicit 0 c by ax y) F(x,     line the of tion Representa Explicit B x dx dy B mx y     0 . . .    dx B y dx x dy
  • 14. Midpoint Line Algorithm lies? point a line the of side which know we do How ) 2 1 , 1 ( )    p p x x F F(M of sign the Check         line the below points for line the above points for line the on points for y x F 0 0 0 ) , ( line the below or above lies Q if test To
  • 15. Midpoint Line Algorithm d variable decison a Define NE or E Choose d   0 ) 2 1 , 1    p p y F(x d E Choose Q) M d   above is ( 0 NE Choose Q) below is (M d   0 E NE M Previous Pixel Current Pixel Choices Next Pixel Choices ) , ( p p y x P  Q
  • 16. Midpoint Line Algorithm value the in change the on based Add directly F(M) of value the compute not Do  • What happens at the next grid point? – Depends on whether we choose N or NE • If E is chosen c y b x a y x F d p p p p new         ) 2 1 ( ) 2 ( ) 2 1 , 2 ( c y b x a d p p old      ) 2 1 ( ) 1 ( a d d old new   dy a d d old new E      E) choose we after d in increment E (  E N E M Previo us Pixel Current Pixel Choices Next Pixel Choices ) , ( p p y x P  Q
  • 17. Midpoint Line Algorithm • If NE is chosen c y b x a y x F d p p p p new         ) 2 3 ( ) 2 ( ) 2 3 , 2 ( NE) choose we after d in increment NE (  c y b x a d p p old      ) 2 1 ( ) 1 ( b a d d old new    dx dy b a d d old new NE        value the in change the on based Add directly F(M) of value the compute not Do  E N E M Previo us Pixel Current Pixel Choices Next Pixel Choices ) , ( p p y x P  Q
  • 18. Midpoint Line Algorithm • Summary – Choose between the two pixels (E/NE) based on the sign of the decision variable d=F(M) – Update the decision variable by adding the change along that direction – Repeat this process until the end point is reached
  • 19. Midpoint Line Algorithm 2 dx dy   d variable decision the for value Initial ) 2 1 , 1     0 0 start y F(x F(M) d c y b x a 0 0      ) 2 1 ( ) 1 ( 2 b a c by ax 0 0      line the on lies ) ,y (x since b a 0 0 2  
  • 20. Midpoint Line Algorithm • Fractional arithmetic still problematic • Should be avoided if possible • Redefine F(x,y) by multiplying by 2 • Thus F(x,y) = 2(ax+by+c) • Replace all constants and the decision variable by 2 • Removes all multiplications; only additions left
  • 21. Midpoint Line Algorithm c) by (ax F(x,y)    2 dx dy b a dstart     2 2 ) ( * 2 dx dy NE    dy E . 2  
  • 22. Midpoint Line Algorithm MidpointLine(x0,y0,x1,y1,color) { int dx,dy,dE,dNE,d,x,y; dx=x1-x0; dy=y1-y0; d=2*dy-dx; dE=2*dy; dNE=2*(dy-dx); x=x0;y=y0; DrawPixel(x,y,color); for(x=x0;x<x1; x++) { if (d<=0) d+=dE ; else {d+=dNE; y++;} DrawPixel(x,y,color); }
  • 23. Bresenham’s Algorithm An example 4 5 6 7 8 9 7 8 9 10 11 12 (x0 , y0 )  (5,8) (x4 , y4 )  (9,11) x  4 y  3 incrE  2y  6 incrNE  2(y  x)  2 d0  2y  x  2  first choice is NE
  • 24. Bresenham’s Algorithm An example 4 5 6 7 8 9 7 8 9 10 11 12 d1  d0  incrNE  2  2  0 second choice is E
  • 25. Bresenham’s Algorithm An example 4 5 6 7 8 9 7 8 9 10 11 12 d2  d1  incrE  0  6  6 third choice is NE