Line Profile

Is there a command to create a line profile? Something where you specify the end points and it returns the pixel values along the line in
say a list. I can brute force it using get pixel but am assuming this will be painfully slow…

The find_line_segments method finds all line segments in the image above an user configurable threshold. Does this do what you need? It’s possible to walk the line segment then looking at every pixel… But, do you need to do that? The method does that internally for you to generate the line ends.

What is your use case?

I’m not looking for lines within an image. I want to find the pixel values along a line I define. One case would be to see how brightness is varying across a known uniform object like a Kodak grey card. Another would be 1D correlation with a pattern. Profiles is something ImageJ does a pretty nice job with. I tend to use ImageJ to develop solutions and then transfer those to application specific code…

You can use img.get_pixel(x, y)

Or if the line is straight use get_statistics. You can define a 1 pixel tall or wide ROI.

Thanks for the responses. Unfortunately I need to define arbitrary lines so get_statistics isn’t going to work. I’ll try img.get_pixel(x, y) but, as I noted in my initial post, I’m concerned it will be painfully slow. If that proves to be the case I’ll explore adding the functionality to base code.



Mmm, okay, so, if you want lots of speed just edit the C code. The find_line_segments function literally does more or less the type of thing you want. It walks a line vector. You can copy its code and create your own function.

However, before doing this I’d prototype all your code in python to see how slow it will be. If you’re planning on walking multiple lines that span the length of the image… then, yes… it will be painfully slow. But, if not it should be decently fast.

Question, what’s you’re use case? We implement generic like things in the firmware. However, what you want to do sounds non-generic…