A function is called injective (or one-to-one, or an injection) if f(a) ≠ f(b) for any two different elements a and b of the domain. It is called surjective (or onto) if f(X) = Y. That is, it is surjective if for every element y in the codomain there is an x in the domain such that f(x) = y. Finally f is called bijective if it is both injective and surjective. This nomenclature was introduced by the Bourbaki group.
The above "color-of-the-shape" function is not injective, since two distinct shapes (the red triangle and the red rectangle) are assigned the same value. Moreover, it is not surjective, since the image of the function contains only three, but not all five colors in the codomain.