at least the first example is a case where limits are applied to an operator. using amsmath, put this in the preamble:
\DeclareMathOperator*{\median}{median}
and enter the math expression as
\[ \hat{f}(x,y)= \median_{(s,t)\in S_{xy}} \left\{g(s,t)\right\} \]
with this result:

\DeclareMathOperator will set the specified string as roman, although other alphabet styles can be specified; the starred version causes strings designated as sub- or superscripts to the operator to be set as limits.
for the second example, it's reasonable to treat this the same way, but specifying italic:
\DeclareMathOperator{\Uoperator}{\mathit{U}}
then ... \Uoperator_{b\in B} ... would yield the requested result.
Uin the second example? I'd say it's\bigcup_{b\in B}