I have a greyscale image in Julia and I'd like to draw a straight line on the image. I have two pairs of coordinates. They represent the start (x1,y1) and end (x2,y2) pixel positions of where the line should start and end. I'm not sure how to find the pixel positions that fall between these two points that need to be coloured in so that my line appears on the image.
I don't want to do this using an interactive tool or annotation for example because I need to do this for many images based on the exact coordinates specified for the image.
My code looks like this so far:
using Images, Colors, ImageView
function convert_rgb_image_to_greyscale(imagefilepath)
img = load(imagefilepath)
my_img_grey = convert(Image{Gray}, my_img)
view(my_img_grey, pixelspacing = [1,1])
return my_img_grey
end
imagefilepath = "myimage.jpg"
my_img_grey = convert_rgb_image_to_greyscale(imagefilepath)
start_pos = [1048 48] # (x1,y1)
end_pos = [1050 155] # (x2,y2)
I've tried looking at Interpolation.jl and some image processing posts on here and blogs etc but I can't seem to get this working.
What I have (ignore the colours)
What I want (ignore the colours)