1. A system comprising: at least one electronic processor coupled to a computer-readable medium, wherein the computer-readable medium comprises computer-executable code that causes the electronic processor to perform the following: providing a target mask, wherein the target mask is in a spatial domain; performing a frequency domain transformation on the target mask to obtain a first mask, wherein the first mask is in a frequency domain; computing a first cost function for a first mask to obtain a first value; altering the first mask in a frequency domain to obtain a second mask, wherein the second mask is in the frequency domain; and computing the first cost function for the second mask to obtain a second value; and repeating the altering the first mask and the computing the first cost function for the second mask until the second value is less than the first value, wherein the second mask or a mask derived from the second mask is used to print a design on a semiconductor wafer using photolithography.