`countNonZero` works with single channel Mat-s, so I suggest use `diff.reshape(1)`.