Is every closed set $K\subseteq \mathbb{C}$ the essential range of a measurable function? For a complex-valued function $h$ on a measure space $(S,\Sigma, \mu)$, the $\textit{essential range}$ of $h$ is the set of all $\lambda \in \mathbb{C}$ such that for all $\epsilon >0$ the pre-image of the open ball $B_\epsilon(\lambda)$ under $h$ has positive measure.
Given a nonempty closed set $K\subseteq \mathbb{C}$, does there exist a measurable function (on $\mathbb{R}$ or $\mathbb{C}$) whose essential range is $K$?
My motivation is to try to prove that for any closed set $K\in \mathbb{C}$ there exists an operator on a Hilbert space $H$ with $\dim H=\infty$ whose spectrum is $K$.  I know that for a multiplicative operator $T_h$ on $L^p(\mu)$ given by $(T_hf)(s)=h(s)f(s)$, the spectrum of $T_h$ is equal to the essential range of $h$. I was hoping to use this result, but perhaps there is an easier way to approach this problem. Still, I was wondering if my above question had a positive or negative answer.
Any hints or help would be great! Thanks!
 A: Yes, every nonempty closed $K$ is the essential range of a measurable function. If $K$ is finite, take a partition of $\mathbb{R}$ into $k$ measurable sets of positive measure, where $k$ is the number of elements of $K$ and take $f = \sum\limits_{j=1}^k a_j\cdot \chi_{M_j}$, where the $a_j$ are the points of $K$ and the $M_j$ the measurable sets. If $K$ is infinite, we can do something very similar, we choose a countable dense subset $\{a_j : j \in \mathbb{Z}^+\}$ of $K$ and consider
$$f = \sum_{j=1}^\infty a_j\cdot \chi_{M_j},$$
where $M_j = [-j,1-j) \cup (j-1,j]$. For a function with domain $\mathbb{C}$, the construction is similar, we can use annuli for the $M_j$ then.
If you are prepared to use non-separable Hilbert spaces, the construction of an operator with given spectrum is even easier, you can use
$$\ell^2(K) = \left\{ f \colon K \to \mathbb{C} \mid \sum_{t\in K} \lvert f(t)\rvert^2 < \infty \right\}$$
and the multiplication by the identity, $T(f) \colon t \mapsto t\cdot f(t)$, which is a densely defined operator with spectrum $K$ (globally defined and continuous iff $K$ is compact).
