When an encoder picks a default quality from the kind of image it was given, the first thing it needs is a cheap way to tell a photo from a screenshot. Edge density is the obvious feature, and on 12 sample images it was the weakest signal. A CC0 airport photo scored 6.3% edge density, above a table screenshot at 4.6%, and a rule of "edge density above 4% means screenshot" filed 5 of the 12 images in the wrong class. Read every number as "these 12 samples", not as an accuracy figure.

What was measured

The 12 images were lossless PNG: three photos and a sky crop of one, three screenshots, a text page, a scanned book page and three illustrations. Edge density here is the share of pixels whose luma differs from a neighbour by 32 or more. Flat share is the share of pixels identical in luma to both the right and the lower neighbour. Hard-edge share is the fraction of clear edges (difference of 16 or more) that jump 96 or more in one step.

Sample Edge density Hard-edge share Flat share Edge rule (above 4% = screenshot)
P1 lake landscape 2.5% 1.2% 11.2% right
P2 portrait 0.8% 0.1% 19.6% right
P3 airport apron 6.3% 2.9% 8.1% wrong
P4 sky crop of P3 3.8% 2.0% 11.0% right
S1 admin table 4.6% 38.0% 91.2% right
S2 dark gradient dashboard 1.7% 28.8% 27.0% wrong
S3 web page with a photo 18.5% 36.3% 57.1% right
T1 text page 11.1% 61.8% 86.8% right
T2 scanned book page 13.4% 23.0% 52.0% right
I1 cartoon apple 3.7% 22.3% 85.7% wrong
I2 anime figure 1.2% 18.2% 93.5% wrong
I3 flat illustration 0.3% 1.2% 90.6% wrong

Why edge density fails in both directions

Edge density counts how many edges there are and says nothing about what kind. Railings and aircraft give the apron photo 6.3%, more than a screenshot that is mostly solid colour with small text. The error runs the other way too: the illustrations and the gradient dashboard sit at 0.3% to 3.7%, so the rule files them as photos. One photo went up and four graphics went down, so no threshold on that column separates them.

The columns beside it do better. The photos sit at 0.1% to 2.9% hard edges, and every other sample except I3 sits at 18.2% or above. I3, a smooth flat illustration at 1.2%, is separated from the photos by its 90.6% flat share. Single-feature rules on these columns each missed one image: hard-edge share above 15% misfiled I3, flat share above 50% misfiled S2. Edge density missed five.

A combination that is a starting point

A rule of near-flat share above 80% with hard-edge share above 15%, or colours per pixel under 0.02, or flat share above 60%, misfiled one image of 12. That was S3, a web page with an embedded photo, whose 325,881 colours look like a photograph's. The dashboard S2 shows why colour count alone is risky: its 55,236 colours look like a photo, and only a near-flat share of 97.2% and a hard-edge share of 28.8% pull it back.

The thresholds were set while looking at these same 12 images and there is no held-out set. It runs, but it is not validated.

Lossy files move the numbers

The above used lossless originals, but files found online rarely are. After saving each image as WebP at quality 80 and decoding it again, the features drifted toward the middle. Photo P1 dropped from 121,313 colours to 39,042 and its flat share rose from 11.2% to 44.4%. Screenshot S1 went the other way, from 1,015 colours to 9,565, and its flat share fell from 91.2% to 82.8%. S2's flat share jumped from 27.0% to 77.4% as WebP turned its gradient into flat blocks, so the flat-above-50% rule made no mistakes on the decoded set. That is compression luck, not a better rule. Thresholds tuned on lossless images need another look before they meet decoded WebP.

What a wrong call costs

The cost is not symmetric. In these notes JPG quality is 80 for photos and 88 for graphics and text (Pillow's libjpeg-turbo, 4:2:0). A photo treated as a screenshot grew by 36.3% to 39.2% for an SSIM gain of 0.0072 to 0.0090. A screenshot treated as a photo came out about a fifth smaller, with SSIM lower by 0.0010 to 0.0067. The SSIM is a luma-only version written for this comparison; no human rating was done.

ImgIng is a browser tool at https://imging.ai/ . After an image goes in, the page names the content type it detected, and the JPG default quality has four steps: 80 for photos, 78 for smooth images, 84 for texture and 88 for graphics and text. The airport apron photo was labelled "Screenshot/UI detected" and got 88. Converting its WebP to JPG at that default gave a file 2.00 times the original WebP, while the other two photos at 80 gave 1.41 and 1.43 times. That is what the page showed on these samples, not how ImgIng decides.

Where this stops holding

Twelve samples, two to four per class, mostly self-rendered screenshots, single runs on one Apple-silicon Mac with Python, Pillow, NumPy and OpenCV. The WebP files came from the originals at quality 80, not from real sites.

Photos are from Wikimedia Commons: Bonnie Moreland's "Lake Mountain Landscape", William Stitt's "Face portrait" and "Avions à l'aéroport de Madrid - 2015", all CC0, scaled and cropped. The web-page screenshot is by Stefan Kühn (CC0), the scanned page comes from 《简化字总表(1986 年新版)》 (public domain mark), and the illustrations are by Toby8991 and oksmith (CC0). The remaining screenshots, text page and flat illustration are self-made with invented data.