DEV Community

Peiguan
Peiguan

Posted on

Is the Forehead or a Cheek Blown Out? A Histogram-Ceiling Check Before a Malfoid AI Upload

A blown highlight is not the same thing as a dark photo, and it is not the same thing as one side of the face being dimmer than the other. If a forehead or a cheek has already hit the top of the histogram, those pixels are a hard white patch. A later still 3:4 portrait will keep them.

I run the studio at Malfoid AI. It makes a still Female Malfoy / Fem Draco portrait, from a photo of an adult or without a photo, for $4.99 / 2 credits. The resolution setting is 1K. There is no video and no prompt box. Credit packs, if you want them, are one-time purchases after sign-in: $13.99 for 30, $35.99 for 100, $59.99 for 200. Prices are from the pricing page, re-checked 27 November 2026, 18:29 Asia/Shanghai, and they have not changed since 31 October 2026. The photos in this article are synthetic construction drawings — shapes only — not studio outputs and not anyone's picture.

This check is a histogram-ceiling test. It is not a mean-exposure test, not a backlight silhouette (face versus field), and not a left-versus-right lighting ratio. Those are useful, and they answer different questions. It also does not use a forehead-only 99th percentile as the fail signal. It asks a narrower question: has the right edge of the luma histogram, in the forehead or in either cheek, already piled up in the top bins, and is that pile a real island of clipped pixels?

Three ROIs, one 256-bin histogram

The face box comes from the construction drawing (the same oval the other pre-upload scripts already use). Inside that ellipse:

  • the forehead is the upper 36% of the box, which sits above the eyes on these sitters
  • the cheeks are the band from 46% to 82% of the box height, split at the vertical mid-line, under the eyes and above the mouth

For each ROI the script builds a 256-bin Rec.709 histogram and also counts pixels where any RGB channel is 255. One floating-point trap is worth locking down: a true (255, 255, 255) has luma 254.99999999999997 under the usual 0.2126 R + 0.7152 G + 0.0722 B coefficients. numpy.histogram with range=(0, 256) then drops that value into bin 254. The script rounds luma to the nearest integer before it bins, so a hard white patch lands in bin 255.

CEILING_FLOOR = 253
BIN255_FRAC_T = 0.010
ISLAND_FRAC_T = 0.008
CHROMA_CLIP_T = 0.012
TOP3_MASS_HOT = 0.004

luma = np.clip(np.rint(0.2126 * r + 0.7152 * g + 0.0722 * b), 0, 255)
hist, _ = np.histogram(luma[mask], bins=256, range=(0, 256))
bin255_frac = hist[255] / n
top3_mass = hist[253:].sum() / n
ceiling_bin = int(np.where(hist > 0)[0][-1])
Enter fullscreen mode Exit fullscreen mode

It also labels the largest 4-connected island of pixels at or above 253. A compact specular and a blown patch can share a ceiling bin of 255 and still differ by two orders of magnitude in island size. The fail rule uses that:

clipped = (
    bin255_frac >= 0.010
    or island_frac >= 0.008
    or chroma_clip_frac >= 0.012
)
Enter fullscreen mode Exit fullscreen mode

A "hot" warn band exists (ceiling_bin >= 253 and top3_mass >= 0.004 without a fail). In this bench the 21-pixel pinpoint stayed under that mass and was left as ok. I would rather name that honestly than invent a warning the fixtures did not earn.

What the fixtures actually did

Eight sitters, five conditions, PNG and JPEG quality 95: 80 files. The conditions are ok (no added clip), a forehead patch pinned at 255, a left-cheek patch, a right-cheek patch, and a pinpoint specular of 21 pixels on the forehead. The script classified 80/80 of them as expected: 16 ok, 48 clipped, 16 pinpoint still ok. Median analyse time was 26.38 ms.

Seed 1, PNG, is the row I would use as a regression pin:

condition state worst ROI bin255 ceiling island px
ok ok left_cheek 0.0 forehead 189; cheeks 250 0
forehead_clip clipped forehead 0.18358678552700577 255 3501
left_cheek_clip clipped left_cheek 0.25513453271772013 255 (same share)
right_cheek_clip clipped right_cheek 0.25287991163010887 255 (same share)
pinpoint ok forehead 0.0011012060828526481 255 21

Two details in that table are easy to misread. First, the unblown cheeks on seed 1 have a ceiling bin of 250, not a mid-tone number. The cheek band starts low enough that the bottom of the sclera can graze it, and sclera is already near-white. That is why the fail signal is bin 255, the island, and per-channel clip — not "the highest occupied bin looks high." Bin 255 on the unblown forehead is 0.0, and the forehead ceiling is 189.

Second, the pinpoint and the blown forehead share a ceiling of 255 and look nothing like each other. Twenty-one clipped pixels are a catchlight. 3,501 pixels, 0.18358678552700577 of the forehead, is a hole. Across the eight PNG sitters the blown forehead island was always 3,501 pixels (the patch is a fixed ellipse); the bin255 share moved with the sitter, from 0.15204551376704595 to 0.21174549413330107, mean 0.1869060607. Left-cheek shares were higher, mean 0.2597963639, because that ROI is smaller than the forehead. Right cheek mean 0.2574243432. The pinpoint island was always 21 pixels.

JPEG quality 95 does nibble a hard 255. Seed 1's blown forehead dropped to bin255 0.16297850026219193 and 3,429 island pixels; the cheeks to 0.21772010826301544 and 0.2158750197254221. The pinpoint shrank to 17 pixels. Every one of those files still classified the same way as the PNG.

What I would do with a real selfie

If the state is clipped, retake the photo. Lower the highlight: step out of the window, dull the desk lamp, or turn your face a little so the forehead or the cheek is not the brightest thing in the room. Do not count on the generator to invent texture that has already been pinned to 255. If you only have a 21-pixel catchlight, this particular threshold will leave you alone; a different camera, or a real skin highlight that fills two percent of the forehead, will not.

The studio's photo-requirements guide already asks for even light and no heavy filter. This script is a pre-upload check for a more specific failure: the histogram has nowhere left to go. Upload only a photo you have the right to use — yourself, or an adult who agreed. Acceptable use is short on that point. The look is unofficial fan art, not affiliated with the author, the publishers, or the studios.

The code, the 80 fixtures, and the tests live next to this writing set. Nothing here is a studio result, and nothing here is a sale: on 27 November 2026 the live pricing and FAQ pages still listed $4.99 / 2 credits for one still, with no Black Friday discount on the page.

Top comments (0)