The initial image

is the overlay of two complementary masks

and

. This overlay evolves according to two rules

and

. The result

of evolving

by the first rule

is masked by multiplication with bitmap mask

. The result

of evolving

by the second rule

is masked by multiplication with the inverted bitmask

which is taken to be
. The sum of the results

and

gives the next image

.
The rule numbers

and

specify two of the 1024 totalistic 9-neighbor two-color cellular automaton rules.
In this Demonstration mask

and its negative

can display (1) the selected rule numbers, (2) a number which gives the number of the current step, (3) static random patterns, or (4) a new random pattern for each step.
Note that the sums of the masked automaton results are always positive. Differences of those intermediary masked results can give negative values. However, taking the absolute value makes negative results of differences acceptable for the next step of evolution by the binary automaton rules

and

.