SlideShare a Scribd company logo
1 of 10
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 sm4Roziq Bahtiar
 
【演習】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 partsdicosmo178
 
Blur Filter - Hanpo
Blur Filter - HanpoBlur Filter - Hanpo
Blur Filter - HanpoHanpo Cheng
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivationKumar
 
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
 
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
 
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 solutionssusere0a682
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing DesignV Tripathi
 
solucionario de purcell 2
solucionario de purcell 2solucionario de purcell 2
solucionario de purcell 2José Encalada
 
solucionario de purcell 1
solucionario de purcell 1solucionario de purcell 1
solucionario de purcell 1José 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

Interpolation functions
Interpolation functionsInterpolation functions
Interpolation functionsTarun Gehlot
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural networkIldar Nurgaliev
 
Modul 3 quadratic function
Modul 3 quadratic functionModul 3 quadratic function
Modul 3 quadratic functionHafidz Mukhtar
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.Mohd Arif
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimediasaranyan75
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivessaranyan75
 
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.pdfRajuSingh806014
 
2.10 translations of graphs t
2.10 translations of graphs t2.10 translations of graphs t
2.10 translations of graphs tmath260
 
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-softmaxTomonari Masada
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithmPooja Dixit
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output PrimitivesPrathimaBaliga
 
10CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 610CSL67 CG LAB PROGRAM 6
10CSL67 CG LAB PROGRAM 6Vanishree Arun
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxNaveenaKarthik3
 
Difference quotient algebra
Difference quotient algebraDifference quotient algebra
Difference quotient algebramath260
 
Lesson20 Tangent Planes Slides+Notes
Lesson20   Tangent Planes Slides+NotesLesson20   Tangent Planes Slides+Notes
Lesson20 Tangent Planes Slides+NotesMatthew Leingang
 

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

Use of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxUse of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxRenuJangid3
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.Silpa
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticssakshisoni2385
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)Areesha Ahmad
 
The Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxThe Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxseri bangash
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsSérgio Sacani
 
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...Monika Rani
 
Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Silpa
 
Proteomics: types, protein profiling steps etc.
Proteomics: types, protein profiling steps etc.Proteomics: types, protein profiling steps etc.
Proteomics: types, protein profiling steps etc.Silpa
 
(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...
(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...
(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...Scintica Instrumentation
 
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate ProfessorThyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate Professormuralinath2
 
Chemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdfChemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdfSumit Kumar yadav
 
GBSN - Microbiology (Unit 3)
GBSN - Microbiology (Unit 3)GBSN - Microbiology (Unit 3)
GBSN - Microbiology (Unit 3)Areesha Ahmad
 
pumpkin fruit fly, water melon fruit fly, cucumber fruit fly
pumpkin fruit fly, water melon fruit fly, cucumber fruit flypumpkin fruit fly, water melon fruit fly, cucumber fruit fly
pumpkin fruit fly, water melon fruit fly, cucumber fruit flyPRADYUMMAURYA1
 
Climate Change Impacts on Terrestrial and Aquatic Ecosystems.pptx
Climate Change Impacts on Terrestrial and Aquatic Ecosystems.pptxClimate Change Impacts on Terrestrial and Aquatic Ecosystems.pptx
Climate Change Impacts on Terrestrial and Aquatic Ecosystems.pptxDiariAli
 
Call Girls Ahmedabad +917728919243 call me Independent Escort Service
Call Girls Ahmedabad +917728919243 call me Independent Escort ServiceCall Girls Ahmedabad +917728919243 call me Independent Escort Service
Call Girls Ahmedabad +917728919243 call me Independent Escort Serviceshivanisharma5244
 
Digital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxDigital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxMohamedFarag457087
 
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIACURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIADr. TATHAGAT KHOBRAGADE
 

Recently uploaded (20)

Use of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxUse of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptx
 
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICEPATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
 
The Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxThe Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptx
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
 
Clean In Place(CIP).pptx .
Clean In Place(CIP).pptx                 .Clean In Place(CIP).pptx                 .
Clean In Place(CIP).pptx .
 
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
 
Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.
 
Proteomics: types, protein profiling steps etc.
Proteomics: types, protein profiling steps etc.Proteomics: types, protein profiling steps etc.
Proteomics: types, protein profiling steps etc.
 
(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...
(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...
(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...
 
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate ProfessorThyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
 
Chemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdfChemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdf
 
GBSN - Microbiology (Unit 3)
GBSN - Microbiology (Unit 3)GBSN - Microbiology (Unit 3)
GBSN - Microbiology (Unit 3)
 
pumpkin fruit fly, water melon fruit fly, cucumber fruit fly
pumpkin fruit fly, water melon fruit fly, cucumber fruit flypumpkin fruit fly, water melon fruit fly, cucumber fruit fly
pumpkin fruit fly, water melon fruit fly, cucumber fruit fly
 
Climate Change Impacts on Terrestrial and Aquatic Ecosystems.pptx
Climate Change Impacts on Terrestrial and Aquatic Ecosystems.pptxClimate Change Impacts on Terrestrial and Aquatic Ecosystems.pptx
Climate Change Impacts on Terrestrial and Aquatic Ecosystems.pptx
 
Call Girls Ahmedabad +917728919243 call me Independent Escort Service
Call Girls Ahmedabad +917728919243 call me Independent Escort ServiceCall Girls Ahmedabad +917728919243 call me Independent Escort Service
Call Girls Ahmedabad +917728919243 call me Independent Escort Service
 
Digital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxDigital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptx
 
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIACURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
 

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)