Phase-retrieval method and applications