Fitting to multiple lines to measure center of a cross in a photo

조회 수: 1 (최근 30일)
John
John 2013년 6월 5일
Hi,
I have a set of black and white pixels. By looking, you can tell the white pixels make up a cross. I would like to find the equations of the 2 best fit lines, so that I can find the intersection and measure the center of the cross to sub-pixel accuracy. How would one best fit one dataset to two different equations?
I have also played around with Hough Transform based line finding, but it does not seem to "best fit" the line; namely my hough results are lines that are not well centered.
-Jen

채택된 답변

Matt J
Matt J 2013년 6월 5일
편집: Matt J 2013년 6월 5일
Well, you would first need to segment the white pixels as belonging to one line or the other. The results of the Hough transform would probably be useful for that.
Once you have the (i,j) coordinates of pixels on a given line as column vectors I and J, you can fit it using total least squares
c=mean([I,J]).';
[u,s,v]=svd( [ I-c(1),J-c(2) ] ,0);
The parametric equation for the line is then
L(t)= c+t*v(:,1)
When you have the parametric equation for both lines, you would solve for the intersection.
  댓글 수: 3
Matt J
Matt J 2013년 6월 5일
편집: Matt J 2013년 6월 5일
Well, HOUGHLINES should have given you enough information to construct moderately accurate equations for both lines and so you can calculate the distance of each white pixel to each line. You would assign each white pixel to the closest line.
John
John 2013년 6월 5일
Thanks! I think I got it to work quite nicely

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 6월 5일
Can you upload your picture to http://snag.gy so we can see it. I'm wondering if the cross is tilted. If it's not tilted, it's simpler.
What about just finding the centroid of the cross, or the weighted centroid? I'm not sure finding where lines cross would be any more accurate than that, at least for crosses that are made up of straight bars.
  댓글 수: 1
John
John 2013년 6월 5일
Surely. http://snag.gy/ZaIYD.jpg The cross is tilted.
I can try a centroid, but I'm not confident because my cross is not always evenly distributed (ie some arms are always going to be longer than others, because it is actually a manual selection from a larger photo)

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by