def draw_line(x0, x1, y0, y1, image, value)
      steep = ((y1-y0).abs) > ((x1-x0).abs)
      if steep
        x0,y0 = y0,x0
        x1,y1 = y1,x1
      end
      if x0 > x1
        x0,x1 = x1,x0
        y0,y1 = y1,y0
      end
      deltax = x1-x0
      deltay = (y1-y0).abs
      error = (deltax / 2).to_i
      y = y0
      ystep = nil
      if y0 < y1
        ystep = 1
      else
        ystep = -1
      end
      for x in x0..x1
        if steep
          begin
            image[y,x] = value # (switching variables)
          rescue
            # Our line has gone outside the image. Do nothing for now, but the proper thing to do would be to at least return some status boolean indicating that this has occured.
          end
        else
          begin
            image[x,y] = value
          rescue
            # Our line has gone outside the image.
          end
        end
        error -= deltay
        if error < 0
          y += ystep
          error += deltax
        end
      end
      return image
    end
def draw_line(x0, x1, y0, y1, image, value)
      steep = ((y1-y0).abs) > ((x1-x0).abs)
      if steep
        x0,y0 = y0,x0
        x1,y1 = y1,x1
      end
      if x0 > x1
        x0,x1 = x1,x0
        y0,y1 = y1,y0
      end
      deltax = x1-x0
      deltay = (y1-y0).abs
      error = (deltax / 2).to_i
      y = y0
      ystep = nil
      if y0 < y1
        ystep = 1
      else
        ystep = -1
      end
      for x in x0..x1
        if steep
          begin
            image[y,x] = value # (switching variables)
          rescue
            # Our line has gone outside the image. Do nothing for now, but the proper thing to do would be to at least return some status boolean indicating that this has occured.
          end
        else
          begin
            image[x,y] = value
          rescue
            # Our line has gone outside the image.
          end
        end
        error -= deltay
        if error < 0
          y += ystep
          error += deltax
        end
      end
      return image
    end
Draws a single line in the (NArray) image matrix based on a start- and
 an end-point. The method uses an iterative Bresenham Line Algorithm.
 Returns the processed image array.

 @param [Array] x0 the column index of the starting point
 @param [Array] x1 the column index of the end point
 @param [Array] y0 the row index of the starting point
 @param [Array] y1 the row index of the end point
 @param [NArray] image a two-dimensional numerical pixel array
 @param [Integer] value the value used for marking the pixel line
 @return [NArray] a pixel array marked with the single line