how to fit two parallel lines

I have the datas(the red points in the pictures) that should be fitted into two parallel lines, do matlab have any functions that could fit multiple data to ensure the fitted lines are parallel?

4 Comments

KSSV
KSSV on 26 Sep 2017
Where is image?
Raelyn
Raelyn on 26 Sep 2017
I'm so sorry, can you see the figure now?
Jan
Jan on 26 Sep 2017
I see 4 read lines.
Raelyn
Raelyn on 26 Sep 2017
two lines are fitted using single methed

Sign in to comment.

Answers (2)

KSSV
KSSV on 26 Sep 2017

2 votes

3 Comments

Raelyn
Raelyn on 26 Sep 2017
thank you so much! That is really helpful! Do you have any suggestion on the noisy points? You can see lots of noisy points that definitely do not belong to the lines?
KSSV
KSSV on 26 Sep 2017
First..how you are plotting these red points?
Raelyn
Raelyn on 26 Sep 2017
the figure was drawn by 400 signals with low SNR(Signal Noise Ratio), the red points are detected by peaks. Since the SNR was low, the peaks may be detected wrongly.

Sign in to comment.

John D'Errico
John D'Errico on 26 Sep 2017

0 votes

The problem is, there are always things in here that you know, but are not telling us.
- Do you have some expectation for the distance between those two lines?
- Why do there appear to be FOUR lines, two of which appear to be fainter than the other two? The pair of spurious lines are not even parallel to the main lines that I see.
Next, assuming there are good answers to the questions I've posed, I'd start by use of image processing techniques.
1. Binarize the image, mapping red pixels to black pixels, everything else to white. (Or vice versa if you prefer.)
2. Use erosion to kill off the extraneous pixels that are alone.
The above steps may result in two or four lines, in a mainly white image.
3. Next, I might apply a Hough transform to the image. This will find lines, though they need not be parallel lines. And it may well find more than 2 lines, since we can see more than two lines. It will give you estimates for the lines you see.
Finally, I might choose to refine the lines so extracted, perhaps using information that you have about the expected lines, and the expected distance between them. This might involve regression methods, if you extract the pixel coordinates. It might involve various statistical methods. You can probably work with the Hough transform tools in the IPT to do much of the work. (I'm not an expert with the IPT.) But the above steps will get you a great deal of the way to a solution.

1 Comment

Raelyn
Raelyn on 26 Sep 2017
These are helpful suggestions. More information is: The figure was drawn by 400 signals with low SNR(Signal Noise Ratio), the red points are detected by peaks. Since the SNR was low, the peaks may be detected wrongly. I want to measure the distance between two lines and other information. I know that the lines are supposed to be parallel.
And also sorry for the four lines, two dashed lines was fitted lines using single data method

Sign in to comment.

Tags

Asked:

on 26 Sep 2017

Commented:

on 26 Sep 2017

Community Treasure Hunt

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

Start Hunting!