SlideShare a Scribd company logo
Presentation on:
Mid- point line
drawing algorithm
SUBMITTED BY: Juhi Kumari
Midpoint algorithm is an incremental algorithm.
Candidate Pixels
Current Pixel
( xk, yk)
Midpoint
Line
Coordinates of Midpoint = ( xk+1, yk+(1/2) )
( xk+1, yk)
( xk+1, yk+1)
Equation of the line:
y-y1/x-x1=y2-y1/x2-x1 ----(1)
Let w = x2  x1, and h = y2  y1
By using equation (1)
y-y1/x-x1=h/w
Then, h (x  x1)  w (y  y1) = 0.
(h, w , x1, y1 are all integers).
In other words, every point (x, y) on the line satisfies the
equation F(x, y) =0, where
F(x, y) = h (x  x1)  w (y  y1).
A(x1,y1)
B(x2,y2)
Decision criteria
F(MP) = Fk =F(xk+1, yk+ ½) ------ (Notation)
If Fk < 0 : The midpoint is above the line. So the
next pixel is (xk+1, yk).
If Fk  0 : The midpoint is below or on the line. So
the next pixel is (xk+1, yk+1).
Choice of the next pixel
Midpoint Below Line
Next pixel = (xk+1, yk+1)
Fk > 0
yk+1 = yk+1
Midpoint Above Line
Next pixel = (xk+1, yk)
Fk < 0
yk+1 = yk
Fk = F(xk+1, yk+ ½)
By using equation,
Fk = h (x  x1)  w (y  y1)
Fk = h (xk+1  x1)  w (yk+½  y1)------(1)
But, Fk+1 = ( xk+1+1, yk+1+(1/2) )
=h(xk+1+1-x1)-w( yk+1+1/2-y1)
= h(xk+2-x1)-w( yk+1+1/2-y1)
Now,
Fk+1 -Fk =h  w (yk+1 yk)
= Fk + h  w (yk+1 yk)
So,
Fk< 0 : yk+1 = yk.
Hence, Fk+1 = Fk + h .
Fk  0 : yk+1 = yk+1.
Hence, Fk+1 = Fk + h  w.
Now, putting k=0 in equation (1), F0 = h  w/2.
int h = y2-y1;
int w = x2-x1;
float F=h-w/2;
int x=x1, y=y1;
for (x=x1; x<=x2; x++)
{
setPixel(x, y);
if(F < 0)
F = F+h;
else{
F = F+h-w;
y++;
}
}
QUES: Find the intermediate pixels of the point (1,2) and
(6,6) using mid point line drawing algorithm?
ANS: Given,
x1=1,y1=2
x2=6,y2=6
now,
h=y2-y1=6-2=4
w=x2-x1=6-1=5
f=(2*h)-w=(2*4)-5=3
Points are: (1,2); (2,3); (3,4); (4,5); (5,6); (6,6)
Mid point

More Related Content

What's hot

Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
Roziq Bahtiar
 
Hog processing
Hog processingHog processing
Hog processing
guestfabb11
 
【演習】Re:ゲーム理論入門 第14回 -仁-
【演習】Re:ゲーム理論入門 第14回 -仁-【演習】Re:ゲーム理論入門 第14回 -仁-
【演習】Re:ゲーム理論入門 第14回 -仁-
ssusere0a682
 
8.2 integration by parts
8.2 integration by parts8.2 integration by parts
8.2 integration by parts
dicosmo178
 
Blur Filter - Hanpo
Blur Filter - HanpoBlur Filter - Hanpo
Blur Filter - Hanpo
Hanpo Cheng
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
Kumar
 
Gaussian Image Blurring in CUDA C++
Gaussian Image Blurring in CUDA C++Gaussian Image Blurring in CUDA C++
Gaussian Image Blurring in CUDA C++
Darshan Parsana
 
Ch1 2 (2)
Ch1 2 (2)Ch1 2 (2)
Ch1 2 (2)
Selvi Thangavel
 
Re:ゲーム理論入門 第16回 - シャープレイ値の応用 -
Re:ゲーム理論入門 第16回 - シャープレイ値の応用 -Re:ゲーム理論入門 第16回 - シャープレイ値の応用 -
Re:ゲーム理論入門 第16回 - シャープレイ値の応用 -
ssusere0a682
 
ゲーム理論BASIC 演習32 -時間決めゲーム:交渉ゲーム-
ゲーム理論BASIC 演習32 -時間決めゲーム:交渉ゲーム-ゲーム理論BASIC 演習32 -時間決めゲーム:交渉ゲーム-
ゲーム理論BASIC 演習32 -時間決めゲーム:交渉ゲーム-
ssusere0a682
 
Overlap Add, Overlap Save(digital signal processing)
Overlap Add, Overlap Save(digital signal processing)Overlap Add, Overlap Save(digital signal processing)
Overlap Add, Overlap Save(digital signal processing)
Gourab Ghosh
 
Integration by parts
Integration by partsIntegration by parts
Integration by parts
MuhammedTalha7
 
TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用
Mark Chang
 
Per de matematica listo.
Per de matematica listo.Per de matematica listo.
Per de matematica listo.
nohelicordero
 
Kalai-smorodinsky bargaining solution
Kalai-smorodinsky bargaining solutionKalai-smorodinsky bargaining solution
Kalai-smorodinsky bargaining solution
ssusere0a682
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing Design
V Tripathi
 
solucionario de purcell 2
solucionario de purcell 2solucionario de purcell 2
solucionario de purcell 2
José Encalada
 
solucionario de purcell 1
solucionario de purcell 1solucionario de purcell 1
solucionario de purcell 1
José Encalada
 
Explanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expertExplanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expert
홍배 김
 

What's hot (19)

Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
 
Hog processing
Hog processingHog processing
Hog processing
 
【演習】Re:ゲーム理論入門 第14回 -仁-
【演習】Re:ゲーム理論入門 第14回 -仁-【演習】Re:ゲーム理論入門 第14回 -仁-
【演習】Re:ゲーム理論入門 第14回 -仁-
 
8.2 integration by parts
8.2 integration by parts8.2 integration by parts
8.2 integration by parts
 
Blur Filter - Hanpo
Blur Filter - HanpoBlur Filter - Hanpo
Blur Filter - Hanpo
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
 
Gaussian Image Blurring in CUDA C++
Gaussian Image Blurring in CUDA C++Gaussian Image Blurring in CUDA C++
Gaussian Image Blurring in CUDA C++
 
Ch1 2 (2)
Ch1 2 (2)Ch1 2 (2)
Ch1 2 (2)
 
Re:ゲーム理論入門 第16回 - シャープレイ値の応用 -
Re:ゲーム理論入門 第16回 - シャープレイ値の応用 -Re:ゲーム理論入門 第16回 - シャープレイ値の応用 -
Re:ゲーム理論入門 第16回 - シャープレイ値の応用 -
 
ゲーム理論BASIC 演習32 -時間決めゲーム:交渉ゲーム-
ゲーム理論BASIC 演習32 -時間決めゲーム:交渉ゲーム-ゲーム理論BASIC 演習32 -時間決めゲーム:交渉ゲーム-
ゲーム理論BASIC 演習32 -時間決めゲーム:交渉ゲーム-
 
Overlap Add, Overlap Save(digital signal processing)
Overlap Add, Overlap Save(digital signal processing)Overlap Add, Overlap Save(digital signal processing)
Overlap Add, Overlap Save(digital signal processing)
 
Integration by parts
Integration by partsIntegration by parts
Integration by parts
 
TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用
 
Per de matematica listo.
Per de matematica listo.Per de matematica listo.
Per de matematica listo.
 
Kalai-smorodinsky bargaining solution
Kalai-smorodinsky bargaining solutionKalai-smorodinsky bargaining solution
Kalai-smorodinsky bargaining solution
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing Design
 
solucionario de purcell 2
solucionario de purcell 2solucionario de purcell 2
solucionario de purcell 2
 
solucionario de purcell 1
solucionario de purcell 1solucionario de purcell 1
solucionario de purcell 1
 
Explanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expertExplanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expert
 

Similar to Mid point

Computer graphics
Computer graphicsComputer graphics
Computer graphics
Shweta Patil
 
Interpolation functions
Interpolation functionsInterpolation functions
Interpolation functions
Tarun Gehlot
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
Ildar Nurgaliev
 
Modul 3 quadratic function
Modul 3 quadratic functionModul 3 quadratic function
Modul 3 quadratic function
Hafidz Mukhtar
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
Sneha Chopra
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.
Mohd Arif
 
Kalman
KalmanKalman
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
saranyan75
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitives
saranyan75
 
monotonicity thoery & solved & execise Module-4.pdf
monotonicity thoery & solved & execise Module-4.pdfmonotonicity thoery & solved & execise Module-4.pdf
monotonicity thoery & solved & execise Module-4.pdf
RajuSingh806014
 
2.10 translations of graphs t
2.10 translations of graphs t2.10 translations of graphs t
2.10 translations of graphs t
math260
 
A note on the density of Gumbel-softmax
A note on the density of Gumbel-softmaxA note on the density of Gumbel-softmax
A note on the density of Gumbel-softmax
Tomonari Masada
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithm
Pooja Dixit
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
PrathimaBaliga
 
Vertex
VertexVertex
10CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 610CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 6
Vanishree Arun
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptx
NaveenaKarthik3
 
Difference quotient algebra
Difference quotient algebraDifference quotient algebra
Difference quotient algebra
math260
 
Lesson20 Tangent Planes Slides+Notes
Lesson20   Tangent Planes Slides+NotesLesson20   Tangent Planes Slides+Notes
Lesson20 Tangent Planes Slides+Notes
Matthew Leingang
 
Parabola
ParabolaParabola

Similar to Mid point (20)

Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Interpolation functions
Interpolation functionsInterpolation functions
Interpolation functions
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
Modul 3 quadratic function
Modul 3 quadratic functionModul 3 quadratic function
Modul 3 quadratic function
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.
 
Kalman
KalmanKalman
Kalman
 
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
 
monotonicity thoery & solved & execise Module-4.pdf
monotonicity thoery & solved & execise Module-4.pdfmonotonicity thoery & solved & execise Module-4.pdf
monotonicity thoery & solved & execise Module-4.pdf
 
2.10 translations of graphs t
2.10 translations of graphs t2.10 translations of graphs t
2.10 translations of graphs t
 
A note on the density of Gumbel-softmax
A note on the density of Gumbel-softmaxA note on the density of Gumbel-softmax
A note on the density of Gumbel-softmax
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithm
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Vertex
VertexVertex
Vertex
 
10CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 610CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 6
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptx
 
Difference quotient algebra
Difference quotient algebraDifference quotient algebra
Difference quotient algebra
 
Lesson20 Tangent Planes Slides+Notes
Lesson20   Tangent Planes Slides+NotesLesson20   Tangent Planes Slides+Notes
Lesson20 Tangent Planes Slides+Notes
 
Parabola
ParabolaParabola
Parabola
 

Recently uploaded

在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
vluwdy49
 
Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.
Aditi Bajpai
 
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdfwaterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
LengamoLAppostilic
 
SAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdfSAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdf
KrushnaDarade1
 
Sharlene Leurig - Enabling Onsite Water Use with Net Zero Water
Sharlene Leurig - Enabling Onsite Water Use with Net Zero WaterSharlene Leurig - Enabling Onsite Water Use with Net Zero Water
Sharlene Leurig - Enabling Onsite Water Use with Net Zero Water
Texas Alliance of Groundwater Districts
 
Bob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdfBob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdf
Texas Alliance of Groundwater Districts
 
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
David Osipyan
 
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốtmô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
HongcNguyn6
 
Medical Orthopedic PowerPoint Templates.pptx
Medical Orthopedic PowerPoint Templates.pptxMedical Orthopedic PowerPoint Templates.pptx
Medical Orthopedic PowerPoint Templates.pptx
terusbelajar5
 
NuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyerNuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyer
pablovgd
 
Equivariant neural networks and representation theory
Equivariant neural networks and representation theoryEquivariant neural networks and representation theory
Equivariant neural networks and representation theory
Daniel Tubbenhauer
 
Deep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless ReproducibilityDeep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless Reproducibility
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
Thornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdfThornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdf
European Sustainable Phosphorus Platform
 
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
University of Maribor
 
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
yqqaatn0
 
ESR spectroscopy in liquid food and beverages.pptx
ESR spectroscopy in liquid food and beverages.pptxESR spectroscopy in liquid food and beverages.pptx
ESR spectroscopy in liquid food and beverages.pptx
PRIYANKA PATEL
 
Cytokines and their role in immune regulation.pptx
Cytokines and their role in immune regulation.pptxCytokines and their role in immune regulation.pptx
Cytokines and their role in immune regulation.pptx
Hitesh Sikarwar
 
molar-distalization in orthodontics-seminar.pptx
molar-distalization in orthodontics-seminar.pptxmolar-distalization in orthodontics-seminar.pptx
molar-distalization in orthodontics-seminar.pptx
Anagha Prasad
 
Basics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different formsBasics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different forms
MaheshaNanjegowda
 
Oedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptxOedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptx
muralinath2
 

Recently uploaded (20)

在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
 
Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.
 
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdfwaterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
 
SAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdfSAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdf
 
Sharlene Leurig - Enabling Onsite Water Use with Net Zero Water
Sharlene Leurig - Enabling Onsite Water Use with Net Zero WaterSharlene Leurig - Enabling Onsite Water Use with Net Zero Water
Sharlene Leurig - Enabling Onsite Water Use with Net Zero Water
 
Bob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdfBob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdf
 
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
 
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốtmô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
 
Medical Orthopedic PowerPoint Templates.pptx
Medical Orthopedic PowerPoint Templates.pptxMedical Orthopedic PowerPoint Templates.pptx
Medical Orthopedic PowerPoint Templates.pptx
 
NuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyerNuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyer
 
Equivariant neural networks and representation theory
Equivariant neural networks and representation theoryEquivariant neural networks and representation theory
Equivariant neural networks and representation theory
 
Deep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless ReproducibilityDeep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless Reproducibility
 
Thornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdfThornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdf
 
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
 
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
 
ESR spectroscopy in liquid food and beverages.pptx
ESR spectroscopy in liquid food and beverages.pptxESR spectroscopy in liquid food and beverages.pptx
ESR spectroscopy in liquid food and beverages.pptx
 
Cytokines and their role in immune regulation.pptx
Cytokines and their role in immune regulation.pptxCytokines and their role in immune regulation.pptx
Cytokines and their role in immune regulation.pptx
 
molar-distalization in orthodontics-seminar.pptx
molar-distalization in orthodontics-seminar.pptxmolar-distalization in orthodontics-seminar.pptx
molar-distalization in orthodontics-seminar.pptx
 
Basics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different formsBasics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different forms
 
Oedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptxOedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptx
 

Mid point

  • 1. Presentation on: Mid- point line drawing algorithm SUBMITTED BY: Juhi Kumari
  • 2. Midpoint algorithm is an incremental algorithm. Candidate Pixels Current Pixel ( xk, yk) Midpoint Line Coordinates of Midpoint = ( xk+1, yk+(1/2) ) ( xk+1, yk) ( xk+1, yk+1)
  • 3. Equation of the line: y-y1/x-x1=y2-y1/x2-x1 ----(1) Let w = x2  x1, and h = y2  y1 By using equation (1) y-y1/x-x1=h/w Then, h (x  x1)  w (y  y1) = 0. (h, w , x1, y1 are all integers). In other words, every point (x, y) on the line satisfies the equation F(x, y) =0, where F(x, y) = h (x  x1)  w (y  y1). A(x1,y1) B(x2,y2)
  • 4. Decision criteria F(MP) = Fk =F(xk+1, yk+ ½) ------ (Notation) If Fk < 0 : The midpoint is above the line. So the next pixel is (xk+1, yk). If Fk  0 : The midpoint is below or on the line. So the next pixel is (xk+1, yk+1).
  • 5. Choice of the next pixel Midpoint Below Line Next pixel = (xk+1, yk+1) Fk > 0 yk+1 = yk+1 Midpoint Above Line Next pixel = (xk+1, yk) Fk < 0 yk+1 = yk
  • 6. Fk = F(xk+1, yk+ ½) By using equation, Fk = h (x  x1)  w (y  y1) Fk = h (xk+1  x1)  w (yk+½  y1)------(1) But, Fk+1 = ( xk+1+1, yk+1+(1/2) ) =h(xk+1+1-x1)-w( yk+1+1/2-y1) = h(xk+2-x1)-w( yk+1+1/2-y1) Now, Fk+1 -Fk =h  w (yk+1 yk) = Fk + h  w (yk+1 yk)
  • 7. So, Fk< 0 : yk+1 = yk. Hence, Fk+1 = Fk + h . Fk  0 : yk+1 = yk+1. Hence, Fk+1 = Fk + h  w. Now, putting k=0 in equation (1), F0 = h  w/2.
  • 8. int h = y2-y1; int w = x2-x1; float F=h-w/2; int x=x1, y=y1; for (x=x1; x<=x2; x++) { setPixel(x, y); if(F < 0) F = F+h; else{ F = F+h-w; y++; } }
  • 9. QUES: Find the intermediate pixels of the point (1,2) and (6,6) using mid point line drawing algorithm? ANS: Given, x1=1,y1=2 x2=6,y2=6 now, h=y2-y1=6-2=4 w=x2-x1=6-1=5 f=(2*h)-w=(2*4)-5=3 Points are: (1,2); (2,3); (3,4); (4,5); (5,6); (6,6)