Much more general results are known: no statement of this form can characterize continuous functions, derivatives, Baire class 1 functions, Borel functions, measurable functions, etc.
THEOREM $\;$ There do not exist families of sets of reals $\rm\: \cal A\:,\:\cal B\;$ such that the following statement is true:
$\quad\quad$ for every function $\rm\; f : \mathbb R\to \mathbb R\:,\;\;\; f\:$ is continuous $\iff$ for every $\: A\in {\cal A}\:,\;\; {\rm f}\:(A) \in \cal B$
For the elementary proof see this 1997 Monthly paper by Velleman and for more general results on classes of functions characterizable by images of sets see this paper, whose abstract I have appended below:
For non-empty topological spaces $X$ and $Y$ and arbitrary
families $\cal{A}\subseteq\cal{P}(X)$ and $\cal{B}\subseteq\cal{P}(Y)$ we put
$\cal{C}_{\cal{A},\cal{B}}=\{f\in Y^X\colon(\forall A\in\cal{A})(f[A]\in\cal{B})\}$.
In this paper we will examine
which classes of functions $\cal{F}\subseteq Y^X$
can be represented as $\cal{C}_{\cal{A},\cal{B}}$. We will be mainly
interested in the case
when
$\cal{F}=\cal{C}(X,Y)$ is the class of all continuous functions from $X$ into $Y$.
We prove that for non-discrete Tychonoff space $X$ the class
$\cal{F}=\cal{C}(X,\mathbb{R})$
is not equal to $\cal{C}_{\cal{A},\cal{B}}$ for any
$\cal{A}\subseteq \cal{P}(X)$ and $\cal{B}\subseteq\cal{P}(\mathbb{R})$. Thus, $\cal{C}(X,\mathbb{R})$
cannot be characterized by images of sets.
We also show that none of the
following classes of real functions can be represented as
$\cal{C}_{\cal{A},\cal{B}}$:
upper (lower) semicontinuous functions,
derivatives, approximately continuous functions,
Baire class 1 functions, Borel functions, and measurable functions.