Source: https://www.cs.kent.edu/~wfan/link/photoshop/ch08.pdf