SlideShare a Scribd company logo
Presenting to:-
Prof. Satish Bansal
Presented by:-
Susant Yadav
Saurabh Soni
B.C.A. 3rd (B)
CONTENT
 what is clipping ?
 What is it’s type ?
 What is line clipping ?
 Method to clip the line .
 How and what technique we use for clipping with
example?
 Difference b/w brute-force and cohen-sutharland
algorithm.
CLIPPING
 A clipping is the method by which we can select the image using a
rectangular window and which part we have select by the window it’s
call clipping.
wymax
wymin
wxmin wxmax
wymax
wymin
wxmin wxmax
TYPES OF CLIPPING…!!
There are 3 types of clipping :-
1. Point clipping
2. Line clipping
3. Area clipping
4. Text clipping
LINE CLIPPING
 If we talk about line clipping .so we have three situation –
A. when Both end-points inside the window
So in that situation we do not clip any point.
we keep both end points.
B. When one end point is outside of the window
and one inside the window
So in that situation we clip partially.
C. When both end points are outside the window .
there may be two cases-
1. when both end points outside the window.
so we clip both end points.
2. when both end points outside the window
but the line passes through the window.
so we must solve it’s intersection point.
How we clip the line ?
 There are two method by which we can clip
the line on our computer machine.
1. Brute Force Line Clipping.
2. Cohen-Sutherland line Clipping Algorithm.
Brute Force Line Clipping
Brute force line clipping can be performed as follows:
1. Don’t clip lines with both
end-points within the
window
2. For lines with one end-point
inside the window and one end-point
outside, calculate the intersection
point (using the equation of the line)
and clip from this point out.
Brute Force Line Clipping
3. For lines with both end-points outside the window test
the line for intersection with all of the window
boundaries, and clip appropriately.
Disadvantage:-
 However, calculating line intersections Is
computationally expensive
 Because a scene can contain so many
lines, the brute force approach to clipping is much too
slow
Cohen-Sutherland line Clipping Algorithm
Dr Ivan E. Sutherland co-developed the Cohen-
Sutherland clipping algorithm.
An efficient line clipping algorithm The
key advantage of the algorithm is that it vastly
reduces the number of line intersections that
must be calculated.
Cohen-Sutherland line Clipping Algorithm
Each region has a unique four bit region code.
Region codes indicate the position of the
regions with respect to the window.
above below right left
3 2 1 0
Region Code Legend
1001 1000 1010
0001
0000
Window
0010
0101 0100 0110
below
Line in the window:-Lines completely contained within the window
boundaries have region code [0000] for both end-points so are not clipped.
 Line out of window:-Any lines with a common
set bit in the region codes of both end-points
can be clipped
when Lines In The Window and out of the window
wymax
wymin
wxmin wxmax
Window
P3 [0001]
P6 [0000]
P5 [0000]
P7 [0001]
P10 [0100]
P9 [0000]
P4 [1000]
P8 [0010]
P12 [0010]
P11 [1010]
P13 [0101] P14 [0110]
wymax
wymin
wxmin wxmax
Window
P3 [0001]
P6 [0000]
P5 [0000]
P7 [0001]
P10 [0100]
P9 [0000]
P4 [1000]
P8 [0010]
P12 [0010]
P11 [1010]
P13 [0101] P14 [0110]
Other Lines
Lines that cannot be identified as completely inside or outside
the window may or may not cross the window interior.
These lines are processed as follows:
 Compare an end-point outside the window to a boundary
(choose any order in which to consider boundaries e.g. left,
right, bottom, top) and determine how much can be
discarded.
 If the remainder of the line is entirely inside or outside the
window, retain it or clip it respectively.
 Otherwise, compare the remainder of the line against
the other window boundaries
 Continue until the line is either discarded or a segment
inside the window is found
We can use the region codes to determine which window
boundaries should be considered for intersection
 To check if a line crosses a particular boundary we
compare the appropriate bits in the region codes of its
end-points
 If one of these is a 1 and the other is a 0 then the line
crosses the boundary
Some examples
Consider the line P9 to P10 below
 Start at P10
 From the region codes of the two end-points we
know the line doesn’t cross the left or right
boundary
 Calculate the intersection of the line with
the bottom boundary to generate point P10’
 The line P9 to P10’ is completely inside
the window so is retained
wymax
wymin
wxmin wxmax
Window
P10 [0100]
P9 [0000]
P10’ [0000]
P9 [0000]
Consider the line P3 to P4 below
 Start at P4
 From the region codes of the two end-points we know the line
crosses the left boundary so calculate the intersection point
to generate P4’
 The line P3 to P4’ is completely outside the window so is clipped
wymax
wymin
wxmin wxmax
Window
P4’ [1001]
P3 [0001]
P4 [1000]
P3 [0001]
Consider the line P7 to P8 below
 Start at P7
 From the two region codes of the two end-points we know
the line crosses the left boundary so
calculate the intersection point to
generate P7’
wymax
wymin
wxmin wxmax
Window
P7’ [0000]
P7 [0001] P8 [0010]
P8’ [0000]
After all working we get this window
wymax
wymin
wxmin wxmax
Window
Calculating Line Intersections
Intersection points with the window boundaries are
calculated using the line-equation parameters
 Consider a line with the end-points (x1, y1) and (x2, y2)
 The y-coordinate of an intersection with a vertical window
boundary can be calculated using:
y = y1 + m (xboundary - x1)
where xboundary can be set to either wxmin or wxmax
Calculating Line Intersections (cont…)
 The x-coordinate of an intersection with a horizontal window
boundary can be calculated using:
x = x1 + (yboundary - y1) / m
where yboundary can be set to either wymin or wymax
 m is the slope of the line in question and can be calculated as
m = (y2 - y1) / (x2 - x1)
Compare b/w
Brute force & Cohen-sutherland
Brute force
1. It is slow process method.
2. It is very time consuming
algorithm because if we want to
clip a line so we can calculate all
the condition to check where the
line clip the window and this
process take much time.
3. It is very simple method to clip
the line.
Cohen-Sutherland
1. It is fast process .
2. In this algorithm with the help of
region-code we simply identify that
where is the line clip the window ,
so It takes less time.
3. It is very complicated method .
Program

More Related Content

What's hot

Back face detection
Back face detectionBack face detection
Back face detection
Pooja Dixit
 
Three dimensional concepts - Computer Graphics
Three dimensional concepts - Computer GraphicsThree dimensional concepts - Computer Graphics
Three dimensional concepts - Computer Graphics
Kongunadu College of engineering and Technology, Namakkal
 
Computer Graphics - clipping
Computer Graphics - clippingComputer Graphics - clipping
B. SC CSIT Computer Graphics Unit 1.3 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 1.3 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 1.3 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 1.3 By Tekendra Nath Yogi
Tekendra Nath Yogi
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphicanku2266
 
Attributes of output primitives( curve attributes & area fill attributes)
Attributes of output primitives( curve attributes & area fill attributes)Attributes of output primitives( curve attributes & area fill attributes)
Attributes of output primitives( curve attributes & area fill attributes)
shalinikarunakaran1
 
Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmCohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
Maruf Abdullah (Rion)
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
KKARUNKARTHIK
 
Bezier curve & B spline curve
Bezier curve  & B spline curveBezier curve  & B spline curve
Bezier curve & B spline curve
Arvind Kumar
 
Illumination Models & Shading
Illumination Models & ShadingIllumination Models & Shading
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
Punyajoy Saha
 
2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinatesTarun Gehlot
 
Composite transformations
Composite transformationsComposite transformations
Composite transformationsMohd Arif
 
Color Models Computer Graphics
Color Models Computer GraphicsColor Models Computer Graphics
Color Models Computer Graphics
dhruv141293
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
Laxman Puri
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
Ankit Garg
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
Mani Kanth
 
Anti aliasing
Anti aliasingAnti aliasing
Anti aliasing
Mahmudul Hasan
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
SwatiHans10
 

What's hot (20)

Back face detection
Back face detectionBack face detection
Back face detection
 
Ray tracing
 Ray tracing Ray tracing
Ray tracing
 
Three dimensional concepts - Computer Graphics
Three dimensional concepts - Computer GraphicsThree dimensional concepts - Computer Graphics
Three dimensional concepts - Computer Graphics
 
Computer Graphics - clipping
Computer Graphics - clippingComputer Graphics - clipping
Computer Graphics - clipping
 
B. SC CSIT Computer Graphics Unit 1.3 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 1.3 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 1.3 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 1.3 By Tekendra Nath Yogi
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
 
Attributes of output primitives( curve attributes & area fill attributes)
Attributes of output primitives( curve attributes & area fill attributes)Attributes of output primitives( curve attributes & area fill attributes)
Attributes of output primitives( curve attributes & area fill attributes)
 
Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmCohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
 
Bezier curve & B spline curve
Bezier curve  & B spline curveBezier curve  & B spline curve
Bezier curve & B spline curve
 
Illumination Models & Shading
Illumination Models & ShadingIllumination Models & Shading
Illumination Models & Shading
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
 
Color Models Computer Graphics
Color Models Computer GraphicsColor Models Computer Graphics
Color Models Computer Graphics
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
 
Anti aliasing
Anti aliasingAnti aliasing
Anti aliasing
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
 

Similar to line clipping

Lecture 2d point,curve,text,line clipping
Lecture   2d point,curve,text,line clippingLecture   2d point,curve,text,line clipping
Lecture 2d point,curve,text,line clippingavelraj
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clipping
Shweta Shah
 
Clipping
ClippingClipping
Clipping
Rajapriya82
 
Lect 5 2d clipping
Lect 5 2d clippingLect 5 2d clipping
Lect 5 2d clipping
majicyoung
 
ohu.pptx
ohu.pptxohu.pptx
ohu.pptx
nabingyawali5
 
kgv.pptx
kgv.pptxkgv.pptx
kgv.pptx
sandeshbhusal6
 
Clipping
ClippingClipping
Clipping
nehrurevathy
 
ibuib.pptx
ibuib.pptxibuib.pptx
ibuib.pptx
nabingyawali5
 
Unit2- line clipping.pptx
Unit2- line clipping.pptxUnit2- line clipping.pptx
Unit2- line clipping.pptx
RYZEN14
 
Unit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdfUnit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdf
Amol Gaikwad
 
Unit 4 notes
Unit 4 notesUnit 4 notes
Unit 4 notes
Balamurugan M
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
ABDULSAMADKAZI
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
ShaishavShah8
 
Clipping
ClippingClipping
ydyu.pptx
ydyu.pptxydyu.pptx
ydyu.pptx
nabingyawali5
 
Unit 3
Unit 3Unit 3
Unit 3
ypnrao
 
Comparison of Various Line Clipping Algorithm for Improvement
Comparison of Various Line Clipping Algorithm for ImprovementComparison of Various Line Clipping Algorithm for Improvement
Comparison of Various Line Clipping Algorithm for Improvement
IJMER
 

Similar to line clipping (20)

Lecture 2d point,curve,text,line clipping
Lecture   2d point,curve,text,line clippingLecture   2d point,curve,text,line clipping
Lecture 2d point,curve,text,line clipping
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clipping
 
Clipping
ClippingClipping
Clipping
 
Lect 5 2d clipping
Lect 5 2d clippingLect 5 2d clipping
Lect 5 2d clipping
 
Clipping
ClippingClipping
Clipping
 
ohu.pptx
ohu.pptxohu.pptx
ohu.pptx
 
kgv.pptx
kgv.pptxkgv.pptx
kgv.pptx
 
Clipping
ClippingClipping
Clipping
 
ibuib.pptx
ibuib.pptxibuib.pptx
ibuib.pptx
 
Unit2- line clipping.pptx
Unit2- line clipping.pptxUnit2- line clipping.pptx
Unit2- line clipping.pptx
 
Unit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdfUnit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdf
 
Unit 4 notes
Unit 4 notesUnit 4 notes
Unit 4 notes
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
Clipping
ClippingClipping
Clipping
 
ydyu.pptx
ydyu.pptxydyu.pptx
ydyu.pptx
 
Unit 3
Unit 3Unit 3
Unit 3
 
lecture8 clipping
lecture8 clippinglecture8 clipping
lecture8 clipping
 
Comparison of Various Line Clipping Algorithm for Improvement
Comparison of Various Line Clipping Algorithm for ImprovementComparison of Various Line Clipping Algorithm for Improvement
Comparison of Various Line Clipping Algorithm for Improvement
 
Clipping
ClippingClipping
Clipping
 

Recently uploaded

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 

Recently uploaded (20)

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 

line clipping

  • 1. Presenting to:- Prof. Satish Bansal Presented by:- Susant Yadav Saurabh Soni B.C.A. 3rd (B)
  • 2. CONTENT  what is clipping ?  What is it’s type ?  What is line clipping ?  Method to clip the line .  How and what technique we use for clipping with example?  Difference b/w brute-force and cohen-sutharland algorithm.
  • 3. CLIPPING  A clipping is the method by which we can select the image using a rectangular window and which part we have select by the window it’s call clipping. wymax wymin wxmin wxmax wymax wymin wxmin wxmax
  • 4. TYPES OF CLIPPING…!! There are 3 types of clipping :- 1. Point clipping 2. Line clipping 3. Area clipping 4. Text clipping
  • 5. LINE CLIPPING  If we talk about line clipping .so we have three situation – A. when Both end-points inside the window So in that situation we do not clip any point. we keep both end points. B. When one end point is outside of the window and one inside the window So in that situation we clip partially.
  • 6. C. When both end points are outside the window . there may be two cases- 1. when both end points outside the window. so we clip both end points. 2. when both end points outside the window but the line passes through the window. so we must solve it’s intersection point.
  • 7. How we clip the line ?  There are two method by which we can clip the line on our computer machine. 1. Brute Force Line Clipping. 2. Cohen-Sutherland line Clipping Algorithm.
  • 8. Brute Force Line Clipping Brute force line clipping can be performed as follows: 1. Don’t clip lines with both end-points within the window 2. For lines with one end-point inside the window and one end-point outside, calculate the intersection point (using the equation of the line) and clip from this point out.
  • 9. Brute Force Line Clipping 3. For lines with both end-points outside the window test the line for intersection with all of the window boundaries, and clip appropriately. Disadvantage:-  However, calculating line intersections Is computationally expensive  Because a scene can contain so many lines, the brute force approach to clipping is much too slow
  • 10. Cohen-Sutherland line Clipping Algorithm Dr Ivan E. Sutherland co-developed the Cohen- Sutherland clipping algorithm. An efficient line clipping algorithm The key advantage of the algorithm is that it vastly reduces the number of line intersections that must be calculated.
  • 11. Cohen-Sutherland line Clipping Algorithm Each region has a unique four bit region code. Region codes indicate the position of the regions with respect to the window. above below right left 3 2 1 0 Region Code Legend 1001 1000 1010 0001 0000 Window 0010 0101 0100 0110 below
  • 12. Line in the window:-Lines completely contained within the window boundaries have region code [0000] for both end-points so are not clipped.  Line out of window:-Any lines with a common set bit in the region codes of both end-points can be clipped when Lines In The Window and out of the window wymax wymin wxmin wxmax Window P3 [0001] P6 [0000] P5 [0000] P7 [0001] P10 [0100] P9 [0000] P4 [1000] P8 [0010] P12 [0010] P11 [1010] P13 [0101] P14 [0110] wymax wymin wxmin wxmax Window P3 [0001] P6 [0000] P5 [0000] P7 [0001] P10 [0100] P9 [0000] P4 [1000] P8 [0010] P12 [0010] P11 [1010] P13 [0101] P14 [0110]
  • 13. Other Lines Lines that cannot be identified as completely inside or outside the window may or may not cross the window interior. These lines are processed as follows:  Compare an end-point outside the window to a boundary (choose any order in which to consider boundaries e.g. left, right, bottom, top) and determine how much can be discarded.  If the remainder of the line is entirely inside or outside the window, retain it or clip it respectively.
  • 14.  Otherwise, compare the remainder of the line against the other window boundaries  Continue until the line is either discarded or a segment inside the window is found We can use the region codes to determine which window boundaries should be considered for intersection  To check if a line crosses a particular boundary we compare the appropriate bits in the region codes of its end-points  If one of these is a 1 and the other is a 0 then the line crosses the boundary
  • 15. Some examples Consider the line P9 to P10 below  Start at P10  From the region codes of the two end-points we know the line doesn’t cross the left or right boundary  Calculate the intersection of the line with the bottom boundary to generate point P10’  The line P9 to P10’ is completely inside the window so is retained wymax wymin wxmin wxmax Window P10 [0100] P9 [0000] P10’ [0000] P9 [0000]
  • 16. Consider the line P3 to P4 below  Start at P4  From the region codes of the two end-points we know the line crosses the left boundary so calculate the intersection point to generate P4’  The line P3 to P4’ is completely outside the window so is clipped wymax wymin wxmin wxmax Window P4’ [1001] P3 [0001] P4 [1000] P3 [0001]
  • 17. Consider the line P7 to P8 below  Start at P7  From the two region codes of the two end-points we know the line crosses the left boundary so calculate the intersection point to generate P7’ wymax wymin wxmin wxmax Window P7’ [0000] P7 [0001] P8 [0010] P8’ [0000]
  • 18. After all working we get this window wymax wymin wxmin wxmax Window
  • 19. Calculating Line Intersections Intersection points with the window boundaries are calculated using the line-equation parameters  Consider a line with the end-points (x1, y1) and (x2, y2)  The y-coordinate of an intersection with a vertical window boundary can be calculated using: y = y1 + m (xboundary - x1) where xboundary can be set to either wxmin or wxmax
  • 20. Calculating Line Intersections (cont…)  The x-coordinate of an intersection with a horizontal window boundary can be calculated using: x = x1 + (yboundary - y1) / m where yboundary can be set to either wymin or wymax  m is the slope of the line in question and can be calculated as m = (y2 - y1) / (x2 - x1)
  • 21. Compare b/w Brute force & Cohen-sutherland Brute force 1. It is slow process method. 2. It is very time consuming algorithm because if we want to clip a line so we can calculate all the condition to check where the line clip the window and this process take much time. 3. It is very simple method to clip the line. Cohen-Sutherland 1. It is fast process . 2. In this algorithm with the help of region-code we simply identify that where is the line clip the window , so It takes less time. 3. It is very complicated method .