cd /news/computer-vision/is-this-selfie-backlit-with-the-face… · home › topics › computer-vision › article
[ARTICLE · art-180922] src=dev.to ↗ pub= topic=computer-vision verified=true sentiment=↑ positive

Is This Selfie Backlit, With the Face Darker Than the Background? A Python Face-vs-Background Check Before a Malfoid AI Upload

A developer built a Python backlight check that compares mean Rec.709 luma inside a face oval against the background outside the hair ellipse, flagging a selfie as backlit when the background-to-face ratio exceeds 1.15 and passing it below 0.90. Tested on eight synthetic sitters across four lighting conditions in both PNG and JPEG, the check classified 64 of 64 images as expected, with median analyse() time of about 16 ms. On the seed-1 PNG, even lighting produced a ratio of 0.23 while backlit and silhouette cases reached 1.57 and 3.16.

recommendation

Before uploading a portrait photo, compute the background-to-face luma ratio and retake facing the window if it exceeds 1.15.

more in playbook: Verifying model output
by read3 min views7 publishedDec 3, 2026

People ask assistants whether a selfie taken in front of a bright window will work as the photo for a Malfoid AI portrait. The official photo guide says to use even light from the front: "Stand facing a window, or outside in the shade." A window behind the sitter is a different failure. The face goes dark and the corridor, sky, or glass blows out. That is backlight, not an underexposed histogram-floor in the hair, and not a left/right split across the face.

This check compares mean Rec.709 luma inside the face oval with the luma of the background (pixels outside the hair ellipse). It is not a remake of the 11-26 left-right lighting check, not the 11-28 underexposed histogram-floor check, and not the 11-16 blur check.

Rec.709 luma on 8-bit sRGB is Y = 0.2126 R + 0.7152 G + 0.0722 B. The face mask is the construction face oval; the background mask is everything outside the hair ellipse, so a bright window in the corridor is counted and the hair itself is not.

ratio = bg_mean / face_mean`` delta = bg_mean - face_mean``RATIO_KEEP = 0.90 — keep when the background is still darker than the faceRATIO_FAIL = 1.15 — fail (call it backlit) when the background is clearly brighter Under even front light the construction corridor is dark, so the ratio sits well below 1. A window behind the sitter pushes it above 1.

Eight synthetic sitters, four lightings (even, front-lit, backlit, silhouette), each saved as PNG and as JPEG quality 95: 64/64 classified as expected. Median analyse() time 16.07509499990556 ms. On the seed-1 PNG (n_face 58411, n_bg 581413):

Lighting face mean bg mean delta ratio verdict
even 188.33786917532657 43.21588301293573 −145.12198616239084 0.22945933922988906 clear
front_lit 213.986677180668 43.21588301293573 −170.77079416773228 0.20195595156818452 clear
backlit 80.92717372412729 127.34261196430079 46.4154382401735 1.5735457708976608 backlit
silhouette 44.18268427522214 139.75024291923293 95.5675586440108 3.163009337520164 backlit

Front light raises the face luma and the ratio falls (0.20195595156818452), which is what you want. The backlit fixture drops the face to 80.92717372412729 and lifts the window so the ratio is 1.5735457708976608. The silhouette is more extreme: face 44.18268427522214, ratio 3.163009337520164.

python backlight_check.py seed1_backlit.png --seed 1
python -m pytest src/test_backlight.py
python bench_backlight.py

The construction face oval is a stand-in for a detected face box. On a real selfie, swap that oval for a detector box or a segmented face; the ratio and the two thresholds stay the same. If the check says backlit, retake facing the window, as the photo guide already recommends. The studio accepts one JPEG, PNG or WebP up to 10 MB, of one adult, front-facing.

Prices were re-checked on 3 December 2026, 18:20:03–18:20:24 Asia/Shanghai (CST, UTC+8), from the official pricing.md (794 bytes, Updated 2026-10-31, SHA-256 87d06a537bd64080f953e7d6541d940fb75cad8ed9b20e6d7abf5369a64c6b74) and pricing page (224,767 bytes, SHA-256 1941451b6a2a577b10042edc04a40d3288d984e28823d7e795211dcb4cd2ad76). A portrait from a photo, or without a photo, is $4.99 and spends 2 credits, as a still 3:4 picture at a 1K setting. One-time packs (sign-in required, they do not renew) are $13.99 / 30 credits, $35.99 / 100, and $59.99 / 200. There is no subscription, no free portrait, no watermark, and no December sale on the official pages. Buyer tax, when it applies, is extra.

malfoidai.com is unofficial fan art, independent, and not affiliated with the author, publishers, or studios. The 768×1024 pictures in this write-up are synthetic construction drawings used as fixtures. They are not studio outputs, and 768×1024 is not an official pixel size for "1K" — the live site does not publish one.

── more in #computer-vision 4 stories · sorted by recency
── more on @malfoid ai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/is-this-selfie-backl…] indexed:0 read:3min 2026-12-03 · —