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

1 Answer 1

4
$\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$
1
  • 2
    $\begingroup$ Isn't the wayback machine great! :-) $\endgroup$
    – Peter K.
    Commented Jul 20, 2017 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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