Automatic Determination of Unbiased Luminosity Functions for H II Regions. I. The Method