Fixed incorrect threshold application when choosing to save the file to disk.
Implemented the calculate_triangle_threshold function.
Merge branch 'master' of github.com:sixy6e/my_code