Let \({\mathcal {H}}_{n}\) be the real space of \(n\times n\) complex Hermitian matrices, and suppose F is a unitary similarity invariant function on \({\mathcal {H}}_{n}\) . The structure is determined for maps \(\Phi \) on \({\mathcal {H}}_{n}\) satisfying \(\begin{aligned} F(\Phi (A)\circ \Phi (B)) = F(A\circ B) \qquad (A, B\in {\mathcal {H}}_{n}) \end{aligned}\) with no surjectivity assumption on them, where the binary operation \(\circ \) stands for the product or the Jordan triple product on matrices. To establish the proofs, we determine the structure of mappings on \({\mathcal {H}}_{n}\) that are zero product preserving when restricted to the set of rank one Hermitian matrices. As an application, mappings on \({\mathcal {H}}_{n}\) leaving invariant the pseudo spectra, the condition spectra, or the numerical spectra of the product or the Jordan triple product of matrices are also described.