This includes different line drawing algorithms,circle,ellipse generating algorithms, filled area primitives,flood fill ,boundary fill algorithms,raster scan fill approaches.
Computer graphics - bresenham line drawing algorithmRuchi Maurya
You know that DDA algorithm is an incremental scan conversion method which performs calculations at each step using the results from the preceding step. Here we are going to discover an accurate and efficient raster line generating algorithm, the Bresenham's line-drawing algorithm.
This algorithm was developed by Jack E. Bresenham in 1962 at IBM.
The function given below handles all lines and implements the complete Bresenham's algorithm.
function line(x0, x1, y0, y1)
boolean steep := abs(y1 - y0) > abs(x1 - x0)
if steep then
swap(x0, y0)
swap(x1, y1)
if x0 > x1 then
swap(x0, x1)
swap(y0, y1)
int deltax := x1 - x0
int deltay := abs(y1 - y0)
real error := 0
real deltaerr := deltay / deltax
int y := y0
if y0 < y1 then ystep := 1 else ystep := -1
for x from x0 to x1
if steep then plot(y,x) else plot(x,y)
error := error + deltaerr
if error ? 0.5
y := y + ystep
error := error - 1.0
Computer graphics - bresenham line drawing algorithmRuchi Maurya
You know that DDA algorithm is an incremental scan conversion method which performs calculations at each step using the results from the preceding step. Here we are going to discover an accurate and efficient raster line generating algorithm, the Bresenham's line-drawing algorithm.
This algorithm was developed by Jack E. Bresenham in 1962 at IBM.
The function given below handles all lines and implements the complete Bresenham's algorithm.
function line(x0, x1, y0, y1)
boolean steep := abs(y1 - y0) > abs(x1 - x0)
if steep then
swap(x0, y0)
swap(x1, y1)
if x0 > x1 then
swap(x0, x1)
swap(y0, y1)
int deltax := x1 - x0
int deltay := abs(y1 - y0)
real error := 0
real deltaerr := deltay / deltax
int y := y0
if y0 < y1 then ystep := 1 else ystep := -1
for x from x0 to x1
if steep then plot(y,x) else plot(x,y)
error := error + deltaerr
if error ? 0.5
y := y + ystep
error := error - 1.0
This slide contain description about the line, circle and ellipse drawing algorithm in computer graphics. It also deals with the filled area primitive.
with today's advanced technology like photoshop, paint etc. we need to understand some basic concepts like how they are cropping the image , tilt the image etc.
In our presentation you will find basic introduction of 2D transformation.
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
This slide contain description about the line, circle and ellipse drawing algorithm in computer graphics. It also deals with the filled area primitive.
with today's advanced technology like photoshop, paint etc. we need to understand some basic concepts like how they are cropping the image , tilt the image etc.
In our presentation you will find basic introduction of 2D transformation.
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
Its a Seminar PPT on Input Devices such as Light Pen & Voice Recoganizer.This is a simple seminar which is easy to understand at the first view itself.
Confessions from Social Media Event Organizers: Taking your brand offlineCheryl Lawson
Event specialist, Cheryl Lawson and Event creator, Denise Quashie delivered this presentation to great response during Geekend2010. See final slide for contact and booking information.
With the growing population of Tweetups, meetups and blogger conferences, social media gurus are becoming overnight DIY event organizers. Sounds okay by us, the professional event organizers, but besides having the chutzpah to pull one off what other tools are required? In this session we’ll explore the needed technology tools—some new, some old and some you never thought were needed for such an event. We’ll present a few case studies, discuss artistic approaches and confess our own pitfalls in being successful social media event organizers.
It gives detailed description about Points, Lines, Attributes of Output Primitives, Line Functions, Line Drawing Algorithms, DDA Line drawing algorithms, Bresenham’s Line Algorithm, Circle Generating Algorthims
Notes for Mechanical and Computer science Students,
In the Notes Including the Basic to algo and transformation in Computer grafics Pixels, it is a important topic
Commonly a fixed area of the system memory is reserved for the frame buffer,
Video controller can direct access to the frame-buffer
Frame-buffer locations, and the corresponding screen positions, are referenced in Cartesian coordinates.
Some system employ lower-left corner as origin
But most common system employ upper-left corner as origin.
Scan lines are labeled from ymax, at the top of the screen to 0 at the bottom.
Along each scan line, screen pixel positions are labeled from 0 to xmax
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
Chapter 3 Output Primitives
1. Objectives
At the end of this chapter the reader will be able to:
• Describe scan conversion
• Describe how to scan convert basic graphic
primitives like point, line, circle, ellipse
3. Output Primitives
● Graphic SW and HW provide subroutines to describe a
scene in terms of basic geometric structures called
output primitives.
● Output primitives are combined to form
complex structures
● Simplest primitives
– Point (pixel)
– Line segment
4. ● Converting output primitives into frame buffer updates.
Choose which pixels contain which intensity value.
● Constraints
– Straight lines should appear as a straight line
– Primitives should start and end accurately
– Primitives should have a consistent brightness
along their length
– They should be drawn rapidly
5. Point plotting is accomplished by converting a single
coordinate position furnished by an application program
into appropriate operations for the output device.
Line drawing is accomplished by calculating intermediate
positions along the line path between two specified end
points positions. An output device is then directed to fill in
these positions between the end points
6. A point is shown by
illuminating a pixel on the
screen
7. A line segment is completely defined in terms of its two
endpoints.
A line segment is thus defined as:
Line_Seg = { (x1, y1), (x2, y2) }
8. y
A line is produced by
means of illuminating a set
of
intermediary
pixels
between the two endpoints.
y2
y1
x1
x2
x
9. Lines is digitized into a set of discrete integer positions
that approximate the actual line path.
Example: A computed line position of (10.48, 20.51) is
converted to pixel position (10, 21).
10. The rounding of coordinate values to integer causes
all but horizontal and vertical lines to be displayed
with a stair step appearance “the jaggies”.
11. To load an intensity value into the frame buffer at a position
corresponding to column x along scan line y,
setpixel (x, y)
To retrieve the current frame buffer intensity setting for a specified
location we use a low level function ,
getpixel (x, y)
13. The Cartesian slope-intercept equation for a straight line is
y = m . x + b (1)
Where m as slope of the line and b as the y intercept
Given that the two endpoints of a line segment are
specified at positions (x1,y1) and (x2,y2) as in figure we can
determine the values for the slope m and y intercept b with
the following calculations
14. m = ∆y / ∆x = y2-y1 / x2 - x1
b= y1 - m . x1
(3)
(2)
Y2
y1
X1
x2
For any given x interval ∆x along a line, we can compute the
corresponding y interval ∆ y
∆y= m ∆x
(4)
We can obtain the x interval ∆x corresponding to a specified ∆y
as
∆ x = ∆ y/m (5)
15. For lines with slope magnitudes |m| < 1, ∆x can be set proportional to a small
horizontal deflection voltage and the corresponding vertical deflection is then set
proportional to ∆y as calculated from Eq (4).
For lines whose slopes have magnitudes |m | >1 , ∆y can be set proportional to a
small vertical deflection voltage with the corresponding horizontal deflection
voltage set proportional to ∆x, calculated from Eq (5)
For lines with m = 1, ∆x = ∆y and the horizontal and vertical deflections voltage
are equal.
Sampling along x axis
Y2
y1
X1
x2
Figure : Straight line Segment with five sampling positions along the x axis between
x1 and x2
16. All line drawing algorithms make use of the fundamental
equations:
Line Eqn. y = m.x + b
Slope m = y2 − y1 / x2 − x1 = Δy / Δx
y-intercept b = y1 − m.x1
x-interval→Δx = Δy / m
y-interval→ Δy = m Δx
17. A line algorithm Based on calculating either Δy or Δx using the
above equations.
There are two cases:
Positive slop
Negative slop
18. If m ≤ 1 then take Δx = 1
Compute successive y by
yk+1 = yk + m
(1)
Subscript k takes integer values starting from 1, for the
first point, and increases by 1 until the final end point is
reached.
Since 0.0 < m ≤ 1.0, the calculated y values must be
rounded to the nearest integer pixel position.
19. If m > 1, reverse the role of x and y and take Δy = 1,
calculate successive x from
xk+1 = xk + 1/m
(2)
In this case, each computed x value is rounded to the
nearest integer pixel position.
The above equations are based on the assumption
that lines are to be processed from left endpoint to
right endpoint.
20. In case the line is processed from Right endpoint to Left
endpoint, then
Δx = −1, yk+1 = yk − m
or
Δy = −1, xk+1 = xk −1/m
for m ≤ 1
for m > 1
(3)
(4)
21. If m < 1,
use(1) [provided line is calculated from left to right] and
use(3) [provided line is calculated from right to left].
If m ≥ 1
use (2) or (4).
22. Faster than the direct use of line Eqn.
It eliminates the multiplication in line Eqn.
For long line segments, the true line Path may be
mislead due to round off.
Rounding operations and floating-point arithmetic are
still time consuming.
The algorithm can still be improved.
Other algorithms, with better performance also exist.
23. Start with starting and ending coordinates of the line:
(x0, y0) and (x1, y1)
Color first pixel (round to nearest integer)
Suppose x1-x0 > y1-y0 (gentle slope)
There will be x1-x0 steps (# pixels to be colored)
Set x=x0, y=y0
At each step,
increment x by (x1-x0)/numsteps, and
increment y by (y1-y0)/numsteps
For each step, round off x and y to nearest integer, and color
pixel
24. // assume that slope is gentle
DDA(float x0, float x1, float y0, float y1) {
float x, y;
float xinc, yinc;
int numsteps;
numsteps = Round(x1) – Round(x0);
xinc = (x1 – x0) / numsteps;
yinc = (y1 – y0) / numsteps;
x = x0;
y = y0;
ColorPixel(Round(x),Round(y));
for (int i=0; i<numsteps; i++) {
x += xinc;
y += yinc;
ColorPixel(Round(x),Round(y));
}
}
Q: For each step, how many floating
point operations are there?
A: 4
Q: For each step, how many integer
operations are there?
A: 2
25. Suppose we want to draw
a line starting at pixel
(2,3) and ending at pixel
(12,8).
What are the values of
the variables x and y at
each timestep?
What are the pixels
colored, according to the
DDA algorithm?
numsteps = 12 – 2 = 10
xinc = 10/10 = 1.0
yinc = 5/10 = 0.5
t
x
y
R(x)
R(y)
0
2
3
2
3
1
3
3.5
3
4
2
4
4
4
4
3
5
4.5
5
5
4
6
5
6
5
5
7
5.5
7
6
6
8
6
8
6
7
9
6.5
9
7
8
10
7
10
7
9
11
7.5
11
8
10
12
8
12
8
26. It is an efficient raster line generation algorithm.
It can be adapted to display circles and other curves.
The algorithm
After plotting a pixel position (xk, yk) , what is the next
pixel to plot?
Consider lines with positive slope.
27. For a positive slope, 0 < m < 1 and line is starting from left to
right.
After plotting a pixel position (xk, yk) we have two choices for
next pixel:
(xk +1, yk)
(xk +1, yk+1)
28. For a positive slope, 0 < m < 1 and line is starting from left to
right.
After plotting a pixel position (xk, yk) we have two choices for
next pixel:
(xk +1, yk)
(xk +1, yk+1)
29. At position xk +1, we pay
attention to the intersection of
the vertical pixel and the
mathematical line path.
30. At position xk +1, we label
vertical pixel separations
from the mathematical line
path as
dlower , dupper.
31. The y coordinate on the mathematical line at xk+1 is calculated
as
y = m(xk +1)+ b
then
dlower = y − yk
= m (xk +1) + b − yk
and
dupper =(yk +1) − y
= yk +1− m(xk +1)− b
32. To determine which of the two pixels is closest to the line path, we set an
efficient test based on the difference between the two pixel separations
dlower - dupper = 2m (xk +1) − 2yk + 2b - 1
= 2 (Δy / Δx) (xk +1) − 2yk + 2b - 1
Consider a decision parameter pk such that
pk = Δx (dlower - dupper )
= 2Δy.xk − 2Δx.yk + c
where
c = 2Δy + Δx(2b −1)
33. Since Δx > 0, Comparing (dlower and dupper ), would tell
which pixel is closer to the line path; is it yk or yk + 1
If (dlower < dupper )
Then pk is negative
Hence plot lower pixel.
Otherwise
Plot the upper pixel.
34. We can obtain the values of successive decision parameter as
follows:
pk = 2Δy.xk − 2Δx.yk + c
pk+1=2Δy.xk+1−2Δx.yk+1+c
Subtracting these two equations
pk+1− pk = 2Δy (xk+1 − xk) − 2Δx ( yk+1 − yk)
But xk+1 − xk = 1, Therefore
pk+1 = pk +2Δy − 2Δx (yk+1 − yk)
35. ( yk+1 − yk) is either 0 or 1, depending on the sign of pk
(plotting lower or upper pixel).
The recursive calculation of pk is performed at integer x
position, starting at the left endpoint.
p0 can be evaluated as:
p0 = 2Δy − Δx
36. Input the two line end points and store the left end point in (x0 ,
y0 ).
2. Load (x0 , y0 ) into the frame buffer; that is, plot the first point.
3. Calculate the constants Δx, Δy, 2Δy, and 2Δy − 2Δx, and obtain
the starting value for the decision parameter as
1.
p0 = 2Δy − Δx
4. At each xk along the line, starting at k = 0 , perform the following
test: If pk < 0,the next point to plot is (xk +1, yk and
pk+1=pk+2Δy
Otherwise, the next point to plot is (xk +1, yk +1) and
pk+1=pk+2Δy−2Δx
5. Repeat step 4, Δx−1 times.
37. The constants 2Δy and 2Δy − 2Δx are calculated once for
each line to be scan converted.
Hence the arithmetic involves only integer addition and
subtraction of these two constants.
38. To illustrate the algorithm, we digitize the line with endpoints
(20,10) and (30,18). This line has slope of 0.8, with
Δx = 10
Δy =8
The initial decision parameter has the value
p0 = 2Δy − Δx = 6
and the increments for calculating successive decision
parameters are
2 Δy = 16
2 Δy - 2 Δx = -4
39. We plot the initial point (x0 , y0)=(20,10) and determine
successive pixel positions along the line path from the
decision parameter as
K
pk
(xk +1, yk +1)
K
pk
(xk +1, yk +1)
0
6
(21,11)
5
6
(26,15)
1
2
(22,12)
6
2
(27,16)
2
-2
(23,12)
7
-2
(28,16)
3
14
(24,13)
8
14
(29,17)
4
10
(25,14)
9
10
(30,18)
40. A circle is defined as the set of points that are all at a given distance r
from a center point (xc, yc).
For any circle point (x, y), this distance is expressed by the Equation
(x − xc)2 + (y − yc)2 = r 2
We calculate the points by stepping along the x-axis in unit steps
from xc-r to xc+r and calculate y values as
41. There are some problems with this approach:
1.
Considerable computation at each step.
2. Non-uniform spacing between plotted pixels as in this Figure.
42. Problem 2 can be removed using the polar form:
x = xc + r cos θ
y = yc + r sin θ
Using a fixed angular step size, a circle is plotted with equally
spaced points along the circumference.
43. Problem 1 can be overcome by considering the symmetry of circles as
in Figure.
But it still requires a good deal of computation time.
Efficient Solutions
Midpoint Circle Algorithm
44. To apply the midpoint method, we define a circle function:
Any point (x,y) on the boundary of the circle with radius r
satisfies the equation fcircle(x, y)= 0.
45. If the points is in the interior of the circle, the circle function is
negative.
If the point is outside the circle, the circle function is positive.
To summarize, the relative position of any point (x,y) can be
determined by checking the sign of the circle function:
46. The circle function tests in (3) are performed for the mid
positions between pixels near the circle path at each sampling
step. Thus, the circle function is the decision parameter in the
midpoint algorithm, and we can set up incremental
calculations for this function as we did in the line algorithm.
47. This Figure shows the midpoint between the two candidate pixels at
sampling position xk +1. Assuming we have just plotted the pixel at
(xk , yk), we next need to determine whether the pixel at position (xk
+1, yk) or the one at position (xk +1, yk −1) is closer to the circle.
48. Our decision parameter is the circle function (2)
evaluated at the midpoint between these two pixels:
49. If pk < 0, this midpoint is inside the circle and the pixel on scan
line yk is closer to the circle boundary.
Otherwise, the midpoint is outside or on the circle boundary,
and we select the pixel on scan line yk −1.
Successive decision parameters are obtained using incremental
calculations.
50. We obtain a recursive expression for the next decision parameter by evaluating the
circle function at sampling position xk+1 +1 = xk + 2
where yk+1 is either yk or yk-1,depending on the sign of pk.
51. Increments for obtaining pk+1 are either :
2xk+1 +1 (if pk is negative) or
2xk+1 +1− 2yk+1 (if pk is positive)
Evaluation of the terms 2xk+1 and 2yk+1 can also be done
incrementally as:
52. At the start position (0, r), these two terms (2x, 2y) have the
values 0 and 2r, respectively.
Each successive value is obtained by adding 2 to the previous
value of 2x and subtracting 2 from the previous value of 2y.
53. The initial decision parameter is obtained by evaluating the
circle function at the start position (x0 , y0)=(0, r):
54. If the radius r is specified as an integer, we can simply round p0
to
since all increments are integers.
55. As in Bresenham’s line algorithm, the midpoint method
calculates pixel positions along the circumference of a
circle using integer additions and subtractions, assuming
that the circle parameters are specified in screen
coordinates.
56.
57. Given a circle radius r = 10, we demonstrate the midpoint circle
algorithm by determining positions along the circle octant in
the first quadrant from x = 0 to x = y . The initial value of the
decision parameter is
58. For the circle centered on the coordinate origin, the initial
point is (x0 , y0) =(0,10), and initial increment terms for
calculating the decision parameters are
Successive decision parameter values and positions along
the circle path are calculated using the midpoint method as
shown in the table.
59.
60. Ellipse equations are greatly simplified if the
major and minor axes are oriented to align
with the coordinate axes.
In Fig. 3-22, we show an ellipse in “standard
position” with major and minor axes oriented
parallel to the x and y axes.
Parameter rx for this example labels the
semimajor axis, and parameter ry labels the
semiminor axis.
61. The equation for the ellipse shown in Fig. 3-22 can be written in
terms of the ellipse center coordinates and parameters rx and ry
as
62. Using polar coordinates r and θ, we can also describe the ellipse
in standard position with the parametric equations :
63. The midpoint ellipse method is applied
throughout the first quadrant in two parts.
Figure 3-25 shows the division of the first
quadrant according to the slope of an
ellipse with rx < ry.
64. Regions 1 and 2 (Fig. 3-25) can be processed in various
ways.
We can start at position (0, ry) and step clockwise along the
elliptical path in the first quadrant, shifting from unit steps
in x to unit steps in y when the slope becomes less than
−1.0.
Alternatively, we could start at (rx, 0) and select points in a
counterclockwise order, shifting from unit steps in y to unit
steps in x when the slope becomes greater than −1.0.
65. We define an ellipse function from Eq. 3-37 with (xc , yc) =
(0, 0) as:
which has the following properties:
66. Starting at (0, ry), we take unit steps in the x direction until we
reach the boundary between region 1 and region 2 (Fig. 3-25).
Then we switch to unit steps in the y direction over the
remainder of the curve in the first quadrant.
At each step we need to test the value of the slope of the curve.
67. The ellipse slope is calculated from Eq. 3-39 as
At the boundary between region 1 and region 2, dy/dx =
−1.0 and
Therefore, we move out of region 1 whenever
68. Figure 3-26 shows the midpoint between the two candidate
pixels at sampling position xk +1 in the first region.
Assuming position (xk , yk) has been selected in the
previous step, we determine the next position along the
ellipse path by evaluating the decision parameter (that is,
the ellipse function 3-39) at this midpoint:
69. If p1k < 0, the midpoint is inside the ellipse and the pixel on scan
line yk is closer to the ellipse boundary.
Otherwise, the mid position is outside or on the ellipse
boundary, and we select the pixel on scan line yk − 1.
70. At the next sampling position (xk+1 + 1 = xk + 2), the decision
parameter for region 1 is evaluated as
72. At the initial position (0, ry), these two terms evaluate to :
As x and y are incremented, updated values are obtained by adding
2r 2y to the current value of the increment term in Eq. 3-45 and
subtracting 2r 2x from the current value of the increment term in Eq.
3-46.
The updated increment values are compared at each step, and we
move from region 1 to region 2 when condition 3-42 is satisfied.
73. In region 1, the initial value of the decision parameter is
obtained by evaluating the ellipse function at the start position
(x0, y0) = (0, ry):
74. Over region 2, we sample at unit intervals in the negative y
direction, and the midpoint is now taken between horizontal
pixels at each step (Fig. 3-27).
For this region, the decision parameter is evaluated as
75. If p2k > 0, the midposition is outside the ellipse boundary, and
we select the pixel at xk.
If p2k <= 0, the midpoint is inside or on the ellipse boundary,
and we select pixel position xk+1.
76. To determine the relationship between successive decision
parameters in region 2,we evaluate the ellipse function at the
next sampling step yk+1 −1 = yk −2:
77. When we enter region 2, the initial position (x0, y0) is
taken as the last position selected in region 1 and the
initial decision parameter in region 2 is then
78.
79.
80. Given input ellipse parameters rx =8 and ry = 6, we illustrate the
steps in the midpoint ellipse algorithm by determining raster
positions along the ellipse path in the first quadrant.
Initial values and increments for the decision parameter
calculations are
81. For region 1, the initial point for the ellipse centered on the
origin is (x0, y0) = (0, 6), and the initial decision parameter value
is
Successive midpoint decision parameter values and the pixel
positions along the ellipse are listed in the following table.
82. For region 1, the initial point for the ellipse centered on the
origin is (x0, y0) = (0, 6), and the initial decision parameter value
is
Successive midpoint decision parameter values and the pixel
positions along the ellipse are listed in the following table.
83.
84. We now move out of region 1, since
2r 2 y x > 2r 2 x y.
For region 2, the initial point is
(x0, y0) = (7, 3)
and the initial decision parameter is
86. A plot of the calculated positions for the ellipse within
the first quadrant is shown bellow:
87. A standard output primitive in general graphics packages is a solidcolor or patterned polygon area.
There are two basic approaches to area filling on raster systems:
1. The scan-line approach
Determine the overlap intervals for scan lines that cross the area.
is typically used in general graphics packages to fill polygons,
circles, ellipses
2. Filling approaches
start from a given interior position and paint outward from this
point until we encounter the specified boundary conditions.
useful with more complex boundaries and in interactive painting
systems.
88. Scan-Line Fill Algorithm:
For each scan line crossing a polygon, the area-fill algorithm locates
the intersection points of the scan line with the polygon edges.
These intersection points are then sorted from left to right, and the
corresponding frame-buffer positions between each intersection pair
are set to the specified fill color.
89.
90. Calculations performed in scan-conversion and other graphics
algorithms typically take advantage of various coherence properties
of a scene that is to be displayed.
Coherence is simply that the properties of one part of a scene are
related in some way to other parts of the scene so that the
relationship can be used to reduce processing.
Coherence methods often involve incremental calculations applied
along a single scan line or between successive scan lines.
91. Area-filling algorithms and other graphics processes often need to
identify interior regions of objects.
To identify interior regions of an object graphics packages normally
use either:
1.
2.
Odd-Even rule
Nonzero winding number rule
92. Odd-Even rule (Odd Parity Rule, Even-Odd Rule):
Draw a line from any position P to a distant point outside the
co ordinate extents of the object and counting the number of edge
crossings along the line.
If the number of polygon edges crossed by this line is odd then
P is an interior point.
Else
P is an exterior point
93. Nonzero Winding Number Rule :
Counts the number of times the polygon edges wind around a
particular point in the counterclockwise direction. This count is
called the winding number, and the interior points of a twodimensional object are defined to be those that have a nonzero value
for the winding number.
1. Initializing the winding number to Zero.
2. Imagine a line drawn from any position P to a distant point
beyond the coordinate extents of the object.
94. Nonzero Winding Number Rule :
3. Count the number of edges that cross the line in each
direction. We add 1 to the winding number every time we
intersect a polygon edge that crosses the line from right to
left, and we subtract 1 every time we intersect an edge that
crosses from left to right.
4. If the winding number is nonzero, then
P is defined to be an interior point
Else
P is taken to be an exterior point.
95.
96. Start at a point inside a region and paint the interior outward
toward the boundary. If the boundary is specified in a single color,
the fill algorithm proceeds outward pixel by pixel until the boundary
color is encountered.
It is useful in interactive painting packages, where interior points
are easily selected.
The inputs of the this algorithm are:
• Coordinates of the interior point (x, y)
• Fill Color
• Boundary Color
97. Starting from (x, y), the algorithm tests neighboring
pixels to determine whether they are of the boundary color.
If not, they are painted with the fill color, and their
neighbors are tested. This process continues until all pixels
up to the boundary have been tested.
There are two methods for proceeding to neighboring
pixels from the current test position:
99. void boundaryFill4 (int x, int y, int fillColor, int borderColor)
{
int interiorColor;
/* set current color to fillColor, then perform following operations. */
}
interiorColor =getPixel (x, y);
if ( (interiorColor != borderColor) && (interiorColor != fillColor) )
{
setPixel (x, y); // set color of pixel to fillColor
boundaryFill4 (x + 1, y, fillColor, borderColor);
boundaryFill4 (x - 1, y, fillColor, borderColor);
boundaryFill4 (x, y + 1, fillColor, borderColor);
boundaryFill4 (x, y - 1, fillColor, borderColor);
}
100.
101. 4-connected and 8-connected methods involve heavy recursion
which may consume memory and time. More efficient methods are
used. These methods fill horizontal pixel spans across scan line. This
called a Pixel Span method.
We need only stack a beginning position for each horizontal pixel
span, instead of stacking all unprocessed neighboring positions
around the current position, where spans are defined as the
contiguous horizontal string of positions.
102. Start from the initial interior point, then fill in the contiguous span
of pixels on this starting scan line. Then we locate and stack starting
positions for spans on the adjacent scan lines, where spans are
defined as the contiguous horizontal string of positions bounded by
pixels displayed in the area border color.
At each subsequent step, we unstack the next start position and
repeat the process. An example of how pixel spans could be filled
using this approach is illustrated for the 4-connected fill region in
the following figure.
103.
104.
105. Sometimes we want to fill in (or recolor)
an area that is not defined within a single
color boundary. We can paint such areas by
replacing a specified interior color instead
of searching for a boundary color value.
This approach is called a flood-fill
algorithm.
106. We start from a specified interior point (x, y) and reassign all pixel
values that are currently set to a given interior color with the
desired fill color.
If the area we want to paint has more than one interior color, we
can first reassign pixel values so that all interior points have the
same color. Using either a 4-connected or 8-connected approach,
we then step through pixel positions until all interior points have
been repainted.
107. void floodFill4 (int x, int y, int fillColor, int interiorColor)
{
int color;
/* set current color to fillColor, then perform following operations. */
getPixel (x, y, color);
if (color = interiorColor)
{
setPixel (x, y); // set color of pixel to fillColor
floodFill4 (x + 1, y, fillColor, interiorColor);
floodFill4 (x - 1, y, fillColor, interiorColor);
floodFill4 (x, y + 1, fillColor, interiorColor);
floodFill4 (x, y - 1, fillColor, interiorColor);
}
}
108. Flood-Fill Algorithm (cont.)
void floodFill4 (int x, int y, int fillColor, int interiorColor)
{ int color;
/* set current color to fillColor, then perform following operations. */
getPixel (x, y, color);
if (color = interiorColor)
{
setPixel (x, y); // set color of pixel to fillColor
floodFill4 (x + 1, y, fillColor, interiorColor);
floodFill4 (x - 1, y, fillColor, interiorColor);
floodFill4 (x, y + 1, fillColor, interiorColor);
floodFill4 (x, y - 1, fillColor, interiorColor);
}
}
CS 380