Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2009-04-09 04:57:18

hpeeze
Member
Registered: 2009-04-09
Posts: 1

find points along a line given starting and ending coordinates

im working on a small image analysis program in VB.NET and would like some help in coding an algorithm that will take the starting and ending points of a line and scan each point in between for a black pixel.

i already have the finding a black pixel part figured out, i just need to figure out how to make the program automatically scan each pixel on a line after i give it the starting and ending points.

here is what im doing to draw t he line(s)

        e.Graphics.DrawLine(Pens.PaleGreen, 194, 43, 180, 47)
        e.Graphics.DrawLine(Pens.PaleGreen, 176, 51, 167, 62)
        e.Graphics.DrawLine(Pens.PaleGreen, 166, 67, 166, 82)
        e.Graphics.DrawLine(Pens.PaleGreen, 167, 87, 175, 99)
        e.Graphics.DrawLine(Pens.PaleGreen, 180, 102, 194, 107)
        e.Graphics.DrawLine(Pens.PaleGreen, 199, 107, 212, 102)
        e.Graphics.DrawLine(Pens.PaleGreen, 216, 100, 226, 87)
        e.Graphics.DrawLine(Pens.PaleGreen, 227, 82, 227, 67)
        e.Graphics.DrawLine(Pens.PaleGreen, 226, 63, 217, 51)
        e.Graphics.DrawLine(Pens.PaleGreen, 214, 48, 199, 43)

as you can see, it draws 10 lines that are slightly separated (will explain the separation part later)
i want to make vb scan each of those lines to see if a black pixel exists underneath it

here is the image im analyzing:
24ytfnn.jpg
NOTE: the image is enlarged to show details, actual size of the image is 320x240
NOTE2: this picture is just temporary to get the basics in place, the end result will be a non distorted and very sharp picture

the red lines represent the lines that VB draws over the existing image
the black pixel im searching for is actually the hand on that dial (represented by the yellow pixel at the intersection of the hand and the red line)

im using getpixel() to get the pixel's color at any given coordinate

eventually the program would scan each dial to find out where the hand is pointing and determine a numerical reading of all of the dials combined.

how would i code an algorithm that will automatically scan each of the lines for a black pixel and stop scanning once it finds a black pixel?

Last edited by hpeeze (2009-04-09 05:15:11)

Offline

Board footer

Powered by FluxBB