Stellar temperature determination for the temperature of its photosphere, the part of the star emitting the electromagnetic radiation (surface temperature), is done (in principle) by treating the spectrum as a black-body spectrum and using Wien's displacement law:
However, only portions of any spectrum are observable through the Earth's atmosphere, and in practice, the shape of the observed spectrum is matched with the black-body spectrum of some temperature, e.g., using the spectral index. Obtaining a relatively full spectrum of the star derives the best such temperature estimate, but requires spectroscopy, from which a spectral type can be determined using spectral features associated with certain temperatures, i.e., the strength of individual spectral lines and their interrelationships. Spectral types derived from color indices using photometry provide a much-easier-to-obtain approximation, very useful for obtaining temperatures of large numbers of stars.
Methods to determine temperatures within the interior depend upon theory, specifically, on models of stellar structure and the associated processes.