matlab - Finding imperfect straight lines in an image -
my task find out green shoots random bush 1
using color segmentation , blob analysis have obtained contour plot of image. find shoots contour plots used hough transforms end giving number of false positives. have tried tuning parameters of both hough lines , peaks either results in number of false positives or false negatives different images. here code snippet
[h,theta,rho] = hough(bw,'theta',-90:1:89,'rhoresolution',1); p = houghpeaks(h,100,'threshold',ceil(0.3*max(h(:))),'nhoodsize',[21 21]); lines = houghlines(bw,theta,rho,p,'fillgap',15,'minlength',100);
can point me better way ?
i had idea, it's long me throw comment.
you identify , label connected components in contour plot image , check different components see if it's long , thin or more blob-like. there bunch of ways test that. first comes mind comparing connected component line runs diagonally across component's bounding rectangle. (but check both ways.) want generate mask each bounding box come across this:
1 1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 1
...and mirror image of it. obviously, need play around bit. add smoothing mask has more tolerance things aren't straight. principle, though, mask by-element multiplied subimage containing component in question. sum of elements in resulting matrix gives score tells how line-like is. if using variable sized mask, need normalize scores somehow. might fail on lines parallel axes, easy enough test because bounding box component long , thin.
failing that, try convolving set of masks of lines @ various angles measure line-likeness @ given point in image, that's going more work , less robust.
Comments
Post a Comment