Final Project (Rule of Thirds detection) - lscott1994/PythonPracticum GitHub Wiki
DetectRuleofThirds.py aims to detect whether the composition of an image complies with the "rule of thirds". The rule of thirds is applied when the subject of an image is aligned with the rule of third guidelines and intersection points of that image. The rule of third guidelines is an invisible grid that divides the image in three, both horizontally and vertically. The intersection points are the four points near the center of the image where the invisible guidelines intersect.
Using the CV2 library, the program reads in a jpeg image. The threshold of the image is increased, which make the objects in the image more distinct. Contours in the image are found using CV2. The intersection points and guidelines are drawn on the image to give the user an idea of where the objects should be if the image complies with the rule of thirds. Rectangle bounds are drawn around the contours previously detected. These are the objects of the image.
Once all the rectangles are drawn, the program checks to see where each object lies in comparison to the four intersection points. If the rectangle is touching an intersection point, then the object is probably complying with the rule of thirds. For every object, a binary list is returned. If a rectangle is touching a point, then the list will add a 1, if it's not, it will add a 0. If the list returns with all 0's, it's still possible that the image is following the rule of thirds with parallelism. The program will check if the corresponding object is running parallel vertically or horizontally to any of the two intersection points. Like the intersection list, if an image is running parallel to two points, 1 is added to the list, else 0 is added. This list is returned to the user.
To further improve my program, I will find a method to give a more definitive answer as to whether the image follows the rule of thirds or not. I would also like to improve on the object detection in my program.
