2
$\begingroup$

I have lines (or segments really) I want to draw into a new image I. Let's define the intensity of the pixel at row = r and col = c as I(r,c). However, the lines are defined by 2 points whose coordinates are not integers.

For example, one line might be from point A (with row = 2.2 and col = 3.5) and to point B with (row = 10.8 and col = 30.4).

What is the algorithm or method for filling in the intensity values of image I at the integer rows and cols?

$\endgroup$
  • 4
    $\begingroup$ Did you look at en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm ? $\endgroup$ – Hilmar Jul 20 '17 at 1:18
  • $\begingroup$ @Hilmar Thank you for mentioning this algorithm I did not know about $\endgroup$ – Laurent Duval Jul 20 '17 at 5:19
  • $\begingroup$ @Hilmar You should add that as an answer, perhaps quoting some of the text. $\endgroup$ – Peter K. Jul 20 '17 at 10:51
3
$\begingroup$

A long time ago I wrote an article on drawing lines with the Wu-Line algorithm. This can be used to draw lines from non-integer coordinates. The effect is very nice to see when animated. You can still find it in the Wayback Machine:

Wu-lines anti-aliased

Wu Anti-aliased Lines from The good-looking textured light-sourced bouncy fun smart and stretchy page

There's also some pseudo-code to get you started.

$\endgroup$
  • 2
    $\begingroup$ Isn't the wayback machine great! :-) $\endgroup$ – Peter K. Jul 20 '17 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.