My requirement is to find the inclination of the lines (all 8 lines) surrounding the data matrix, as shown in the edge detected image:
The two main restrictions:
- The inclination detected should have precision of at least 0.1 deg (the best achievable in this image)
- Time taken should be less than 30 ms
I am implementing the algo on a Blackfin DSP, and have used Blackfin image processing toolbox.
I tried using Hough transform and Contour detection to find out the lines and thus their inclinations however the time limit exceeds. Any suggestions to use a different algorithm or optimize this one would help.
[for my use case the higher the angle precision the better, I am targeting at least 0.02 - 0.05 with a higher resolution image]
find bounding box
scan all points and found
xmin,ymin,xmax,ymax
of set pixelsfind the gaps
cast scan lines through half of bounding box remembering/measure the gap sizes. To avoid line miss (due to holes) you can cast more scan lines or scan with wider ray.
If you need some examples for ray cast/scanning see:
segmentate the image into regions
just shrink bounding box by some fraction (50%) of a gap ... something like this:
forming 8 rectangular regions each one with single line without noise from the edges.
regress/fit lines
The idea is to make a list of all set pixels for each region separately and fit a line that has smallest distance to all of them.
I would try to use this:
n
points on a 2D plane, find the maximum number of points that lie on the same straight lineOr use approximation search and fit something like
just ignore the curvature and fit line equation parameters directly instead cubics.
After the lines are fitted you can compute their slope directly by
atan2(dy,dx)