Transition from amplified spontaneous emission to laser action in strongly scattering media