# Find pixels at given distance along line

2 views (last 30 days)

Show older comments

Hello, as you can see on image attached I´ve computed perpendicular lines to red lines. I know the slope of red line, the slope of green line and I know the coordinates of the cross-section also. So I computed x and y coordinates of the green line as follows:

slope = (r1 - r2) / (s1 - s2); %red line slope

slRec = -1 / slope; %perpendicular green line slope

ym = (y1 + y2)/2; xm = (x1 + x2)/2; %cross-section point

according to well known line equation y = ax + b I´ve counted y when x was created as:

b = ym - a*xm;

length = 5;

y = ym - length : 0.25 : ym + length;

x = (y - b) / a;

coordinates = ([y; x])';

But as you can see on my image, there is problem that when the length of the line is given by y-axis range it is different length itself. How can I find pixel value at unit distance from the red line (and along green line)?

##### 0 Comments

### Answers (1)

Image Analyst
on 1 May 2014

##### 4 Comments

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!