The invention relates to an automatic keystone correction system and method. An original signal and a delayed signal are provided to an average magnitude difference processor for determining an average magnitude difference for a sum of samples representing an envelope of each of the respective original and delayed signals, each for a series of sample delays. The semiconductor wafer is then developed, the alignment mark is etched free and covered again with a second resist, which is exposed in an exposer in order to transfer a mask structure following an alignment with the alignment mark.