Let $f\colon S\to T$ be any function. There is the obvious refinement of $f$, by replacing the codomain $T$ with the image. Thus, every function factors into a surjection followed by an injection (and not just any injection, but an inclusion):
$$
S\twoheadrightarrow {\rm im}(f)\subseteq T.
$$
This situation can be improved even further. Define an equivalence relation $\sim$ on $S$ by saying that $a\sim b$ when $f(a)=f(b)$. Then $f$ factors into three maps:
$\require{AMScd}$
\begin{CD}
S @>f>> T\\
@V \pi V V @AA i A\\
S/{\sim} @>>\overline{f}> {\rm im}(f)
\end{CD}
The map $\pi$ is the canonical surjection to the partition, given by the rule $s\mapsto \overline{s}$. The map $i$ is the stated inclusion map. Finally, the induced map $\overline{f}$, where $\overline{s}\mapsto f(s)$, is a (well-defined) bijection.
While this diagram implicitly occurs throughout abstract algebra, the first time I recall explicitly seeing it was in a homological algebra course (in the context of abelian categories) taught by T. Y. Lam, who called $\overline{f}$ the "makeover" of $f$ (because the TV had been on when he was preparing the lecture, and he happened to catch Jenny Jones talking about makeovers).
I'm preparing to teach this diagram to my (undergraduate) abstract algebra class, as a motivation for the 1st isomorphism theorems of groups and rings. I was wondering if the decomposition $f=i \overline{f}\pi$ has a name, in this general context of sets. I was a little surprised to discover that the decomposition also holds for general universal algebras. Perhaps there a name for the decomposition in that context?
By the way, unless another name is in use, I'm planning to call this result the "flock lemma". The reason is that if we view the elements of $S$ as pigeons, and the elements of $T$ as holes, and the elements of ${\rm im}(f)$ as the inhabited holes, then $S/{\sim}$ is the collection of "flocks of pigeons" organized by which inhabited hole the flock flies to. Feel free (in the comments) to suggest a better name (or vote for "flock lemma").