Alternans, a beat-to-beat alternation in cardiac signals, may serve as a precursor to lethal cardiac arrhythmias, including ventricular tachycardia and ventricular fibrillation. Therefore, alternans is a desirable target of early arrhythmia prediction/detection. For long-term records and in the presence of noise, the definition of alternans is qualitative and ambiguous. This makes their automatic detection in large spatiotemporal data sets almost impossible. We present here a quantitative combinatorics-derived definition of alternans in the presence of random noise and a novel algorithm for automatic alternans detection using criteria like temporal persistence (TP), representative phase (RP) and alternans ratio (AR). This technique is validated by comparison to theoretically-derived probabilities and by test data sets with white noise. Finally, the algorithm is applied to ultra-high resolution optical mapping data from cultured cell monolayers, exhibiting calcium alternans. Early fine-scale alternans, close to the noise level, were revealed and linked to the later formation of larger regions and evolution of spatially discordant alternans (SDA). This robust new technique can be useful in quantification and better understanding of the onset of arrhythmias and in general analysis of space-time alternating signals.