انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

scan conversion

Share |
الكلية كلية العلوم للبنات     القسم قسم الحاسبات     المرحلة 3
أستاذ المادة رسل محمد نعمة       22/02/2017 03:29:57
Scan Conversion: It’s the process of transformed the points of figure to a correct value of pixel to display on the screen. It s also called (rasterizing). In computer graphics system, there are two steps are necessary in order to display a geometric figure:
(1) a scan-converting algorithm should be executed to select the best pixels (the ones closest to the ideal figure) (2) the selected pixels should be turned on.
Step 2 is simple. It only requires setting bits in the bitmap. Most current compilers have a built-in function to do this. All that the program has to say is PSet(row,col) or plot(r,c,color).
Step 1 is more complex. The scan-converting algorithm has to be fast and it must depend on the shape of the figure. The following algorithms will deal with drawing straight lines, circles and arc.
First, to draw any figure we need to the following aspects: 1- Determine the arithmetic relations and operators to draw the figure. 2- Determine the start point of the draw. 3- Find the others points to draw the figure, that by find: - The amount of increasing of new x, y from the old one. It s must be regular or dependents.
- Find the number of points that required to draw ( find number of iterations of loop to draw). - Find the stop condition of loop .
Line Drawing Algorithms The straight line is the simplest geometric figure. Its explicit equation is: y = ax + b where a is the slope and b is the y-intercept. We have the coordinates of the two endpoints (x1 ,y1 ) and (x2 ,y2 ) of line, therefore it is easy to express a and b in terms of the endpoints.
Computer Graphics Lecture 2 / 3rd Class/2016-2017
2 Ms. C. Rusul mohammed
The slope a is simply (y2 ? y1 )/(x2 ? x1 )or?y/?x. The value of b is obtained from y1 = a * x1 + b, which implies: Our first algorithm uses (x1 ,y1 ) and (x2 ,y2 ) to compute a and b, and then executes loop as in algorithm (1). However, this loop is very slow because it uses multiplications and also because it works with real quantities that have to be rounded to integers. A better algorithm should use just additions/subtractions and just integers.
Algorithm 1: Draw line using slope equation Inputs: (x1, y1) start point, (x2,y2) end point.
Outputs: drawn straight line on screen. Begin
a = (y2 - y1) / (x2 - x1) b = y1 - a * x1 if(x1 > x2) then swap (x1,x2) x = x1 repeat y = a * x + b
Set_Point ( round ( x ), round(y) , color) x = x + 1 until x > x2
End Digital Differential Analyzer (DDA) Algorithm: Better scan-conversion algorithms should be arithmetically simple and should use just integers. The DDA algorithm generates lines from their differential equations.
• The start point will be (x1, y1). • Calculate the length of the line in the X direction ( number of pointes) by the equation :
Diffx = x2 - x1 • Calculate the length of the line in the Y direction ( number of pointes) by the Equation : Diffy=y2-y1

المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم