Hello,
I need a little help on an image analysis algorithm in Java. I basically have images like this:
So, as you might guessed, I need to count the lines.
What approach do you think would be best?
Thanks, Smaug
Hello,
I need a little help on an image analysis algorithm in Java. I basically have images like this:
So, as you might guessed, I need to count the lines.
What approach do you think would be best?
Thanks, Smaug
First, decide the angle that is allowed for a "vertical" line. I'd say 45 degrees.
Then get the background colors - grab the pixles in each corner, for example. Or more properly - get the most predominant colors.
Then start to inspect pixels horizontally. Whenever a non-background color is encountered, assume a line starts there. On the next row of pixels (or after no more than X rows, if it is possible for a line to not be completely continous) check whether there's a non-background color in the "neighbour" pixels, determined by the angle you chose initially. So for 45 degrees you'd have to check more pixels than for 10 degrees.
I'm not sure this is sufficient, and it might yield imperfect results, but there comes your role to optimize it.
A simple segmentation algorithm can help you out. Heres how the algorithm works:
You can do many optimizations in the algorithm according to your needs.
It depends on how much they look like that.
Then,
A lot depends on how good you do #3, some ideas