A pattern-recognition approach to the phase problem: Application to the X-ray diffraction study of biological membranes and model systems