The goal of this challenge is to determine the angle of a line in a image.
Rules on the image:
- The image background will be white (
- The stroke of the line will be black (
- The line will NOT be anti-aliased
- The image will be 100x100 pixels
- The line will start at the center of the image
- The line will start pointing down (6-OClock)
- The line will be 50 pixels long
- The angle of the line will be measured going counterclockwise from the starting position
- The image codec will be either
Input format will be a file name passed by the command line arg, script input, or function arg. Output format is simple - just output the number of degrees (e.g.
Answers can be ±1 degree of the stated measure. Here are a few example images:
A reference image at 45 degrees with gray background
Here is the code used to create the images (this is coded with Processing):
int deg = 45; int centX = width/2, centY = height/2; background(255); noSmooth(); line(centX, centY, centX + sin(radians(deg))*50, centY + cos(radians(deg))*50); saveFrame("line-"+deg+".png");// image codec can be changed here. use '.png' or '.jpg'