Random Face Generation in PaperJS



    Synthetic images usually look unnatural, not human, and a trained eye immediately distinguishes them from real ones. The Weird Faces Study project is an attempt to combine the traditional technique of "human" drawing and computer algorithms. The result is generated computer faces, each of which is unique and looks like an original author's work.

    The Weird Faces Study face generator is written in JavaScript using the PaperJS library as part of the PaperJS training course taught at the University of California, Los Angeles.

    Actually, the algorithm for generating faces consists of 9 steps .

    1. Draw a face shape.
    2. Draw a fold inside the shape.
    3. Find the center of the figure, draw a nose.
    4. Draw eyes based on the location of the nose and the radius so that they do not overlap.
    5. Draw eyebrows based on the location of the eyes and their radius.
    6. Draw a mouth based on the location of the eyes and nose so that they do not overlap.
    7. To draw cheeks, taking into account the shape of the face and the radius of the head.
    8. Draw the ears outside the face.
    9. Draw hair outside the face.

    As a result, the computer creates a minimal set of graphic elements that the human brain recognizes as a face.

    PaperJS is one of several existing web drawing libraries , along with Processing.js and Raphaël.

    Perhaps the algorithms for generating unique faces may come in handy in the future for automatically rendering cartoons based on automatically generated plots .






    Also popular now: