2 dimensional array, calculating maximum value
I'm trying to get the maximum value in a line in an 2d array. For example is this greyscale image. For 开发者_JAVA技巧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.
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
精彩评论