I'm trying to implement a method where I have to obtain the values of all those pixels which forms a line at a certain angle through a pixel (i, j)
Consider the following code snippet
sum = image.getpixel(((i - 7), (j + 2))) + image.getpixel(((i - 6), (j + 2))) + image.getpixel(
((i - 5), (j + 1))) + image.getpixel(
((i - 4), (j + 1))) + image.getpixel(((i - 3), (j + 1))) + image.getpixel(((i - 2), (j + 1))) + image.getpixel(
((i - 1), j)) + image.getpixel((i, j)) + image.getpixel(((i + 1), j)) + image.getpixel(
((i + 2), (j - 1))) + image.getpixel(((i + 3), (j - 1))) + image.getpixel(((i + 4), (j - 1))) + image.getpixel(
((i + 5), (j - 1))) + image.getpixel(((i + 6), (j - 2))) + image.getpixel(((i + 7), (j - 2)))
avg_sum = sum / 15
Now in the above code I know which pixels relative to i, j forms the line at angle 15 degrees. Hence I am able to get the values of all those pixels.
Now is there an easy way to do this because currently this code find the sum of the grey level of 15 pixels that forms this line at 15 degree through i, j. I want this code to be flexible so that I can easily find the sum of line of length 15 pixels or 13 pixels or 11 pixels and so on.