Using the GALACTICA (GALaxy Automated ComponenT Image Construction Algorithm) code of Benson et al., we obtain quantitative measurements of spheroid-to-disc ratios for a sample of 8839 galaxies observed in the Sloan Digital Sky Survey (SDSS). We carry out extensive tests of this code and of GIM2D, finding that they perform similarly in all respects. From the spheroid and disc luminosities, we construct luminosity and stellar mass functions for each component and estimate the relative luminosity and stellar mass densities of discs and spheroids in the local Universe. Assuming a simple one-to-one mapping between spheroid mass and the mass of a central supermassive black hole, we provide the most accurate determination so far of the black hole mass function in the local universe. From this, we infer a cosmological mass density of black holes of rho(center dot) = (3.77 +/- 0.97) x 10(5) h M-circle dot Mpc(-3). We compare our results to predictions from current hierarchical models of galaxy formation and these are found to fare well in predicting the qualitative trends observed. We find that stars in discs contribute 35-51 per cent of the local stellar mass density.