Detecting a line in an image and save its coordinates

Viewed 47

I have an image representing an intensity graph:

intensity graph

In order to multiplicate two intensitiy graphs I need to save the coordinates of this graph. Thus, I first want to find the (middle or one border of the) line and then get its coordinates. So far I tried a few things. Which came nearest to the solution was using the LineSegmentDetector package:

library(pixmap)
image <- read.pnm(file = "graph.pgm", cellres = 1)
x <- image@grey * 255
linesegments <- image_line_segment_detector(x)
linesegments
plot(image)
plot(linesegments, add = TRUE, col = "red")

This gives me a couple of line segments:

enter image description here

However, the aim is to get one line of 1 pixel width like this:

enter image description here

Subsequently, I would need the coordinates of this graph. I would need one y value for every pixel in x direction. I hope my problem is clear and am thankful for any help!

0 Answers
Related