tags:

views:

44

answers:

1

Hey everyone,

I'm trying to get the maximum value in a line in an 2d array. For example is this greyscale image. For me it's no problem to calculate the horizontal and vertical maximum grey value.

However, I don't have a clue how to calculate an angled line (green line) from this 2d array.

Anyone can help me out with this.

alt text

+1  A: 

Do you know the angle of the line?

You can use the sinus and cosinus functions to calculate the x and y values of each point.

var x = Math.Cos(angle) * length
var y = Math.Sin(angle) * length

Where you increase the length each time. You will have to round the x and y values because they won't be integers.

You then use the x and y values as indices for the 2 dimensional arrays

Ikke