Source: https://web.stanford.edu/class/cs279/notes/image-analysis-notes.pdf