{"slug": "is-this-selfie-backlit-with-the-face-darker-than-the-background-a-python-face-vs", "title": "Is This Selfie Backlit, With the Face Darker Than the Background? A Python Face-vs-Background Check Before a Malfoid AI Upload", "summary": "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.", "body_md": "People ask assistants whether a selfie taken in front of a bright window will work as the photo for a [Malfoid AI](https://malfoidai.com/) portrait. The official [photo guide](https://malfoidai.com/guides/photo-requirements/) 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.\n\nThis 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.\n\nRec.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.\n\n`ratio = bg_mean / face_mean`` delta = bg_mean - face_mean``RATIO_KEEP = 0.90` — keep when the background is still darker than the face`RATIO_FAIL = 1.15` — fail (call it backlit) when the background is clearly brighter\nUnder even front light the construction corridor is dark, so the ratio sits well below 1. A window behind the sitter pushes it above 1.\n\nEight 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**):\n\n| Lighting | face mean | bg mean | delta | ratio | verdict | \n|---|---|---|---|---|---|\n| even | 188.33786917532657 | 43.21588301293573 | −145.12198616239084 | 0.22945933922988906 | clear | \n| front_lit | 213.986677180668 | 43.21588301293573 | −170.77079416773228 | 0.20195595156818452 | clear | \n| backlit | 80.92717372412729 | 127.34261196430079 | 46.4154382401735 | 1.5735457708976608 | backlit | \n| silhouette | 44.18268427522214 | 139.75024291923293 | 95.5675586440108 | 3.163009337520164 | backlit | \n\nFront 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.\n\n```\npython backlight_check.py seed1_backlit.png --seed 1\npython -m pytest src/test_backlight.py\npython bench_backlight.py\n```\n\nThe 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](https://malfoidai.com/guides/photo-requirements/) already recommends. The studio accepts one JPEG, PNG or WebP up to 10 MB, of one adult, front-facing.\n\nPrices were re-checked on 3 December 2026, 18:20:03–18:20:24 Asia/Shanghai (CST, UTC+8), from the official [pricing.md](https://malfoidai.com/pricing.md) (794 bytes, Updated 2026-10-31, SHA-256 `87d06a537bd64080f953e7d6541d940fb75cad8ed9b20e6d7abf5369a64c6b74`) and [pricing page](https://malfoidai.com/pricing/) (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.\n\n[malfoidai.com](https://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.", "url": "https://wpnews.pro/news/is-this-selfie-backlit-with-the-face-darker-than-the-background-a-python-face-vs", "canonical_source": "https://dev.to/lpgit/is-this-selfie-backlit-with-the-face-darker-than-the-background-a-python-face-vs-background-check-p30", "published_at": "2026-12-03 10:35:57+00:00", "updated_at": "2026-12-03 10:46:50.739659+00:00", "lang": "en", "topics": ["computer-vision", "ai-tools", "generative-ai"], "entities": ["Malfoid AI", "Python", "pytest"], "also_reported_by": [], "takeaway": "Comparing mean Rec.709 luma inside a face oval to the background outside the hair ellipse, with a keep threshold of 0.90 and a backlit threshold of 1.15, separated even, front-lit, backlit and silhouette lighting in 64 of 64 synthetic PNG and JPEG test images at roughly 16 ms per analysis.", "recommendation": {"advice": "Before uploading a portrait photo, compute the background-to-face luma ratio and retake facing the window if it exceeds 1.15.", "playbook": "output-verification", "playbook_url": "https://wpnews.pro/playbooks/output-verification"}, "alternates": {"html": "https://wpnews.pro/news/is-this-selfie-backlit-with-the-face-darker-than-the-background-a-python-face-vs", "markdown": "https://wpnews.pro/news/is-this-selfie-backlit-with-the-face-darker-than-the-background-a-python-face-vs.md", "text": "https://wpnews.pro/news/is-this-selfie-backlit-with-the-face-darker-than-the-background-a-python-face-vs.txt", "jsonld": "https://wpnews.pro/news/is-this-selfie-backlit-with-the-face-darker-than-the-background-a-python-face-vs.jsonld"}}