The 'Eye Enlargement Magic' in Beauty SDK: Demystifying the Core Algorithmic Logic

In the beauty needs for live streaming and short videos, "eye enlargement" is one of the most popular functions.
The effect of enlarging eyes with a simple tap hides the elaborately designed algorithmic logic in the beauty SDK.
Below, we will break down this core algorithm for "making eyes more lively" from a technical perspective.
The essence of the eye enlargement effect is "local non-proportional deformation" of the eye area — specifically enlarging only the pixels around the eyes while ensuring the 画面 remains natural. To achieve "naturalness", the algorithm follows two key design principles:
- Gradual Deformation Ratio: The deformation "strength" gradually weakens from the "center" of the deformation area (usually near the eyeball) to the "edge", avoiding a "stiff stretching" feeling when the eyes are enlarged and instead forming a layered transition.
- Edge Non-Deformation: The "outermost edge" of the deformation area remains unchanged, ensuring that the enlarged eyes can "naturally connect" with the surrounding skin and contours, eliminating the sense of incongruity caused by "edge tearing" or "incoherence".
The algorithm defines a circular deformation area (radius denoted as r) for the "eye enlargement" effect, which fits the general shape of human eyes and makes the deformation more in line with visual intuition.
Within this circular area, pixel coordinates undergo "mapping changes":
- In the original image, the distance from a pixel to the "center of the deformation area" is denoted as X;
- After algorithm processing, the distance from the pixel to the "center of the deformation area" in the new image is denoted as Y.
By designing the functional relationship between X and Y (such as the curve relationship shown in the PPT), the effect of "obvious enlargement at the center and gradual weakening at the edge" is achieved: the closer the pixel is to the center of the circle (the smaller X is), the higher the "magnification ratio" of Y relative to X; when the pixel is close to the edge of the circle (X is close to r), the ratio of Y to X gradually approaches 1 (that is, the edge is almost undeformed).
To finely control the "degree of eye enlargement", the algorithm designs a curve relationship for coordinate mapping (such as functions like (y = r × [1 - ln(1 - x/r)/ln(2)])). Different curve parameters (such as the "(a/b/c) parameters" mentioned in the PPT) will bring different "magnification strengths": the steeper the curve, the more significant the enlargement effect in the central area and the stronger the eye enlargement effect; the flatter the curve, the more natural and soft the enlargement effect.
This curve regulation allows the beauty SDK to provide an "eye enlargement intensity" adjustment option — essentially balancing "enlargement effect" and "naturalness" by adjusting curve parameters.
The execution of the eye enlargement algorithm follows a clear process:
- Traverse Pixels of the Original Image: Check each pixel ((u,v)) in the image one by one.
- Determine if in Deformation Area: Calculate the distance from the pixel to the "center of the deformation area" and determine whether it belongs to the circular deformation area. If not (distance exceeds radius r), the pixel remains unchanged ((u' = u), (v' = v)).
- Calculate New Pixel Value via Bilinear Interpolation: If the pixel is within the deformation area, calculate the pixel position in the new image and assign the corresponding value through "bilinear interpolation" combined with the coordinate mapping relationship. The role of bilinear interpolation is to make the pixel transition smoother, avoid "blocky" or "jagged" feelings, and ensure the image remains delicate after eye enlargement.
The eye enlargement algorithm of the beauty SDK may seem like a simple effect of "making eyes bigger", but it actually integrates multiple technical logics such as "region division, gradual deformation, curve regulation, and interpolation smoothing".
It not only meets the aesthetic need of "enlarging eyes" but also ensures the effect is natural and not incongruous through elaborate design, reflecting the core pursuit of beauty technology: "using technology to hide artificial traces and make beauty more smooth and real".
With the continuous optimization of algorithms (such as combining AI to accurately identify eye contours), the future "eye enlargement" effect will be more intelligent and more in line with individual eye characteristics, and "customized beauty" will be getting closer to us.