An optimized algorithm is proposed for the computer drawing of the envelopes of transmission and reflection spectra of a thin dielectric film on a transparent substrate. This allows the optical characterization of the film to be fully computerized using the two envelopes of a given spectrum. Optical characterization is performed for a model system by transmission and reflection spectra with noise for different film thicknesses. Computation is also made for an experimental transmission spectrum of an a-Si:H film on a quartz substrate. Higher consistency in the determination of the refractive index of the film n(λ) is achieved when it is calculated in the final step of the algorithm by the extremum condition and not by the two envelopes.