For assignment 2, we had to use mylar to recreate a 3D image by taping the mylar to a window and drawing the contour.
I found this incredibly difficult, as it required me to close an eye and stay in the exact same position.
For every new line I added, I had to check roughly half of the lines already on the mylar to make sure that I was still in the correct position.
This algorithm is O(n^2) because for each new line added, a linear proportion of existing lines must be checked.
The algorithm to draw with aligned perspectives has a constant time insert because no other lines need to be referred to, therefore O(n) time.
After about an hour, it became obvious that I needed a better solution.
OpenCV is a python package that allows for image transformations and uses numpy for data/array management.
These are some basic functions that I used to produce images that helped me finish the assignment:
- cv2.cvtColor(img, cv2.COLOR_RGB2GRAY): given an image img, this function call will return the grayscaled image.
- cv2.GaussianBlur(img, (n, n {where n % 2 != 0}), 0): Given img and blur size, GaussianBlur will remove some of the more irrelevant edges.
- cv2.Canny(img, n, m): Canny is the edge detection function, and (n, m) are
- click here for more details on the math of edge detection.