ADescribe · describe.images
Image collection profile (size, color, sharpness, duplicates)
What is in this folder of images — sizes, formats, exposure, blur, camera data and duplicates?
Profiles the images listed in a column of file paths (for example from Discover → Images → Choose a folder): format, pixel size and aspect ratio, brightness and contrast, colorfulness and saturation, sharpness (variance of the Laplacian), EXIF camera data (GPS only as present or absent), perceptual-hash near-duplicates and identical files, and a map that places similar-looking images together. Dark, bright, blurry and duplicate images are flagged against thresholds you set. PNG and JPEG are read identically in Python and R; TIFF files are decoded once by the app and both engines read the same pixels. An optional pretrained embedder (MobileNetV3, about 10 MB, Python only) builds the map after a one-time download you approve.
A real result
Example “Folder defaults”, recorded in both engines. In the app, “Try this example” loads it into Analyze.
22 images: median 62 × 48 px; 1 dark, 1 bright, 2 blurry, 3 in near-duplicate groups.
- Images read
- 22
- Mean brightness
- 0.5090
- Median sharpness
- 697.19
- In duplicate groups
- 3
Plots
View data
| Brightness (0–1) | Flag | File | Sharpness (variance of the Laplacian) |
|---|---|---|---|
| 0.5459 | OK | gradient_a.png | 111.35 |
| 0.5459 | Duplicate | gradient_a_copy.png | 111.35 |
| 0.5458 | Duplicate | gradient_a_near.png | 138.60 |
| 0.3877 | OK | gradient_b.png | 111.66 |
| 0.5002 | OK | stripes_fine.png | 22408.52 |
| 0.5002 | OK | stripes_blurred.png | 427.86 |
| 0.5964 | OK | stripes_wide.png | 4403.90 |
| 0.5294 | OK | checker.png | 35891.72 |
| 0.5096 | OK | checker_gray.png | 27468.42 |
| 0.2080 | OK | checker_alpha.png | 966.52 |
| 0.2885 | Blurry | palette.png | 73.680 |
| 0.0469 | Dark | dark.png | 73.171 |
| 0.9604 | Bright | bright.png | 73.887 |
| 0.5020 | Blurry | flat_mid.png | 0 |
| 0.5971 | OK | portrait.png | 201.51 |
| 0.5170 | OK | wide_banner.png | 2909.27 |
| 0.5925 | OK | photo_a.jpg | 1481.37 |
| 0.5011 | OK | photo_b.jpg | 8914.04 |
| 0.4901 | OK | photo_c.jpg | 10461.76 |
| 0.8435 | OK | plain.jpg | 230.68 |
| 0.4903 | OK | gray.jpg | 18698.44 |
| 0.5003 | OK | stripes_fine_copy.jpg | 22509.03 |
View data
| Format | Height (px) | File | Width (px) |
|---|---|---|---|
| PNG | 48 | gradient_a.png | 64 |
| PNG | 48 | gradient_a_copy.png | 64 |
| PNG | 48 | gradient_a_near.png | 64 |
| PNG | 40 | gradient_b.png | 80 |
| PNG | 64 | stripes_fine.png | 64 |
| PNG | 64 | stripes_blurred.png | 64 |
| PNG | 50 | stripes_wide.png | 90 |
| PNG | 60 | checker.png | 60 |
| PNG | 32 | checker_gray.png | 48 |
| PNG | 40 | checker_alpha.png | 40 |
| PNG | 36 | palette.png | 36 |
| PNG | 40 | dark.png | 60 |
| PNG | 40 | bright.png | 60 |
| PNG | 30 | flat_mid.png | 30 |
| PNG | 90 | portrait.png | 40 |
| PNG | 20 | wide_banner.png | 120 |
| JPEG | 48 | photo_a.jpg | 64 |
| JPEG | 56 | photo_b.jpg | 56 |
| JPEG | 48 | photo_c.jpg | 72 |
| JPEG | 40 | plain.jpg | 40 |
| JPEG | 48 | gray.jpg | 48 |
| JPEG | 64 | stripes_fine_copy.jpg | 64 |
View data
| Flag | File | PC 1 | PC 2 |
|---|---|---|---|
| OK | gradient_a.png | 0.7091 | 2.310 |
| Duplicate | gradient_a_copy.png | 0.7091 | 2.310 |
| Duplicate | gradient_a_near.png | 0.7096 | 2.295 |
| OK | gradient_b.png | −2.834 | 0.6196 |
| OK | stripes_fine.png | −0.0566 | −1.913 |
| OK | stripes_blurred.png | −0.1064 | −1.341 |
| OK | stripes_wide.png | 1.954 | 0.8558 |
| OK | checker.png | 0.6090 | −1.846 |
| OK | checker_gray.png | 0.1656 | −1.966 |
| OK | checker_alpha.png | −6.833 | 0.3521 |
| Blurry | palette.png | −5.269 | 2.574 |
| Dark | dark.png | −10.389 | −1.554 |
| Bright | bright.png | 10.204 | −0.4908 |
| Blurry | flat_mid.png | −0.1527 | −1.524 |
| OK | portrait.png | 2.244 | 2.898 |
| OK | wide_banner.png | −0.3354 | 0.6315 |
| OK | photo_a.jpg | 1.766 | 1.773 |
| OK | photo_b.jpg | −0.2190 | −0.4322 |
| OK | photo_c.jpg | −0.2570 | −0.5075 |
| OK | plain.jpg | 7.662 | −1.198 |
| OK | gray.jpg | −0.2377 | −1.765 |
| OK | stripes_fine_copy.jpg | −0.0436 | −2.080 |
Assumptions
- PNG, JPEG and TIFF — 1 listed files are not PNG, JPEG or a readable kind of TIFF.
- Sharpness depends on size and content — Sharpness is measured at most 512 pixels on the long side; plain images score low without being blurred.
- Personal data in metadata — 1 images carry GPS location data (coordinates are not read).
Flagged images
| File | Flag | Brightness | Sharpness | Duplicate group |
|---|---|---|---|---|
| gradient_a_copy.png | Duplicate | 0.5459 | 111.35 | 1 |
| gradient_a_near.png | Duplicate | 0.5458 | 138.60 | 1 |
| palette.png | Blurry | 0.2885 | 73.680 | 0 |
| dark.png | Dark | 0.0469 | 73.171 | 0 |
| bright.png | Bright | 0.9604 | 73.887 | 0 |
| flat_mid.png | Blurry | 0.5020 | 0 | 0 |
Cameras (EXIF)
| Make and model | Images |
|---|---|
| Fixturecam FX-100 | 1 |
| Fixturecam FX-200 | 1 |
| Othercam O-1 | 1 |
- 1 rows have no path and are left out.
- 1 rows point to files that do not exist and are left out.
- 1 rows are not PNG, JPEG or a readable kind of TIFF and are left out.
- 1 rows could not be decoded and are left out.
22 images: median 62 × 48 px; 1 dark, 1 bright, 2 blurry, 3 in near-duplicate groups.
- Images read
- 22
- Mean brightness
- 0.5090
- Median sharpness
- 697.19
- In duplicate groups
- 3
To keep this page light, the plots are shown once, under the R tab.
Assumptions
- PNG, JPEG and TIFF — 1 listed files are not PNG, JPEG or a readable kind of TIFF.
- Sharpness depends on size and content — Sharpness is measured at most 512 pixels on the long side; plain images score low without being blurred.
- Personal data in metadata — 1 images carry GPS location data (coordinates are not read).
Flagged images
| File | Flag | Brightness | Sharpness | Duplicate group |
|---|---|---|---|---|
| gradient_a_copy.png | Duplicate | 0.5459 | 111.35 | 1 |
| gradient_a_near.png | Duplicate | 0.5458 | 138.60 | 1 |
| palette.png | Blurry | 0.2885 | 73.680 | 0 |
| dark.png | Dark | 0.0469 | 73.171 | 0 |
| bright.png | Bright | 0.9604 | 73.887 | 0 |
| flat_mid.png | Blurry | 0.5020 | 0 | 0 |
Cameras (EXIF)
| Make and model | Images |
|---|---|
| Fixturecam FX-100 | 1 |
| Fixturecam FX-200 | 1 |
| Othercam O-1 | 1 |
- 1 rows have no path and are left out.
- 1 rows point to files that do not exist and are left out.
- 1 rows are not PNG, JPEG or a readable kind of TIFF and are left out.
- 1 rows could not be decoded and are left out.
Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.
Worked examples in the app
- Folder defaultsml_images · image: path
- Coloured by labelml_images · image: path · label: label
- Small analysis sizeml_images · image: path
- Tiff collectionmedia_images_tiff · image: path · label: label
- Tiff mixed folderimages_tiff_mixed · image: path
- Degenerate all naml_images · image: path
- Pdna missing path and labelpdna_images · image: path · label: label
In the guides
Where it sits in the decision guides
- Type: structured (tabular), unstructured (text, images, audio, video), time series / sequential, graph / relational · DS & ML Decision Guide · Key data characteristics — what influences method choice
- Multimodal data exploration (text, image, video) · DS & ML Decision Guide · Describe — summarize and visualize
What you need
- Image pathcategorical · 1 column
- A column of image file paths (PNG, JPEG or TIFF). Relative paths start at the folder below, or next to the data file.
- Color the map bycategorical / boolean · 0–1 column · 1–30 levels
- Optional: a column such as the subfolder or class, used only to color the map.
Choices you make
options
- Folder for relative pathsdefault —
Where relative paths start. Empty uses the folder of the data file; absolute paths ignore it.
statistics
- Map fromdefault classic
The map places similar images close together; classic features need no download.
- Classic features (no download)(default) — Brightness, contrast, color, sharpness, entropy and a 4 × 4 thumbnail, reduced by PCA; identical in Python and R.
- MobileNetV3 (pretrained, ~10 MB, Python) — A small ImageNet network's 1024-value features; groups images by content. Runs locally after a one-time download; Python only.
- Dark belowdefault 0.15
Images whose mean brightness (0–1) is below this are flagged dark.
- Bright abovedefault 0.85
Images whose mean brightness (0–1) is above this are flagged bright (washed out).
- Blurry belowdefault 100
Variance of the Laplacian below this flags an image as blurry. Flat, plain images score low too.
- Near-duplicate distancedefault 6
Perceptual hashes that differ in at most this many of 64 bits count as near-duplicates.
Advanced
- Analysis size (long side)default 512
Measures use a copy this many pixels on its long side (area averaging); sharpness depends on it.
Checks and remedies
CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.
PNG, JPEG and TIFF
Other formats (GIF, WebP, HEIC), CMYK JPEGs and the few kinds of TIFF the app can't decode (palette colors, YCbCr) are listed as unsupported; convert them first. A multi-page TIFF is read from its first page.
Sharpness depends on size and content
The Laplacian variance falls when an image is small, plain or soft; compare images of similar size and subject.
Personal data in metadata
Photos can carry location and camera serials. Only GPS presence is reported; consider stripping metadata before sharing.
What it reports
- n_rows
- How many independent units the analysis used; it sets precision and power.
- n_images
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- n_no_path
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- n_missing
- How many independent units the analysis used; it sets precision and power.
- n_unsupported
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- n_unreadable
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- n_png
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- n_jpeg
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- n_alpha
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- bytes_total
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- width_min
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- width_median
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- width_max
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- height_min
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- height_median
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- height_max
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- megapixels_median
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- aspect_median
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- share_portrait
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- n_sizes
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- brightness_mean
- Brightness is an image's mean luminance on 0–1; contrast is how much luminance varies; colorfulness how vivid and varied its colors are.
- brightness_sd
- Brightness is an image's mean luminance on 0–1; contrast is how much luminance varies; colorfulness how vivid and varied its colors are.
- contrast_mean
- Brightness is an image's mean luminance on 0–1; contrast is how much luminance varies; colorfulness how vivid and varied its colors are.
- colourfulness_mean
- Brightness is an image's mean luminance on 0–1; contrast is how much luminance varies; colorfulness how vivid and varied its colors are.
- saturation_mean
- Brightness is an image's mean luminance on 0–1; contrast is how much luminance varies; colorfulness how vivid and varied its colors are.
- sharpness_median
- The variance of an image's second-derivative (edge) response: sharp images have strong edges and a high value, blurry ones a low value.
- entropy_mean
- Brightness is an image's mean luminance on 0–1; contrast is how much luminance varies; colorfulness how vivid and varied its colors are.
- n_dark
- Brightness is an image's mean luminance on 0–1; contrast is how much luminance varies; colorfulness how vivid and varied its colors are.
- n_bright
- Brightness is an image's mean luminance on 0–1; contrast is how much luminance varies; colorfulness how vivid and varied its colors are.
- n_blurry
- The variance of an image's second-derivative (edge) response: sharp images have strong edges and a high value, blurry ones a low value.
- n_exif
- Data a camera stores inside a photo: make, model, date taken, exposure, orientation and sometimes GPS location.
- n_gps
- Data a camera stores inside a photo: make, model, date taken, exposure, orientation and sometimes GPS location.
- n_dup_groups
- A 64-bit fingerprint of an image's coarse brightness pattern; resized, re-saved or lightly edited copies get fingerprints a few bits apart.
- n_in_dup_groups
- A 64-bit fingerprint of an image's coarse brightness pattern; resized, re-saved or lightly edited copies get fingerprints a few bits apart.
- n_exact_dups
- A 64-bit fingerprint of an image's coarse brightness pattern; resized, re-saved or lightly edited copies get fingerprints a few bits apart.
- map_share_1
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- map_share_2
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
- embedding
- A summary of a folder of images: how many could be read, formats, pixel sizes and shapes, and which were missing or damaged.
Per group, level or term: camera[<make model>], n_tiff
Python and R
Python and R agree to 6 decimals (relative tolerance 1e-9). Python uses pillow, numpy, pandas, pyarrow, codesplash; R uses png, jpeg, nanoparquet, jsonlite, codesplashr.
Default traps between the two languages
- Both engines decode PNG and baseline JPEG to the same pixels (checked on the fixtures; Pillow uses libjpeg-turbo, the jpeg package IJG libjpeg) and run the same twins (codesplash.images.features ↔ codesplashr R/images.R); the remaining differences are matrix-product rounding. JPEGs with chroma subsampling can differ by one gray level between decoders.
- The MobileNetV3 map runs in Python only (onnxruntime); R refuses that choice and keeps the classic map. tests/crosscheck/w3ds2b_images.py runs it on the fixtures when the model is downloaded.
- TIFF files are decoded once by the app (the image crate, in the sandboxed sidecar) and both engines read the same 8-bit pixels, so TIFF rows agree exactly; they equal Pillow's pixels for the same file read without its Orientation tag (runtimes/python/tests/test_images_tiff.py). In exported code Python decodes TIFFs with Pillow and R, which has no TIFF reader, lists them as unsupported.
The exact script CodeSplash ran for example “Folder defaults” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Image collection profile (size, color, sharpness, duplicates)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method describe.images 1.1.0 · spec bcdfced43aa2ed60
# Dataset: ml_images (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import os
import numpy as np
import pandas as pd
import codesplash as cs
from codesplash import ml as csml
from codesplash.images import features as fx
from codesplash.images import tiff as fxt
# %% Images listed in the path column
PATH = "path"
LABEL = None
FOLDER = os.path.expanduser("")
DATA_DIR = os.path.dirname(os.path.abspath("tests/parity/fixtures/ml_images.parquet"))
df = pd.read_parquet("tests/parity/fixtures/ml_images.parquet", columns=[PATH] if LABEL is None else [PATH, LABEL])
# %% Media files (image column path)
# In the app the files were decoded once into float32 arrays (media.json in the run folder). Elsewhere they are
# decoded here the same way: PNG and WAV give the app's values; JPEG, MP3 and other lossy files can differ slightly.
import json as _media_json
from codesplash import media as cs_media
media = cs_media.setup(_media_json.loads("{\"ids_column\":\"media_id\",\"kind\":\"image\",\"path_column\":\"path\",\"role\":\"image\",\"transform\":{\"filter\":\"triangle\",\"fit\":\"original\",\"formats\":[\"tiff\"],\"mode\":\"rgb\",\"normalize\":\"none\",\"orientation\":\"stored\",\"size\":[224,224]}}"), "target/academy-parity/run-8142/describe.images/folder_defaults/out-python", df, "tests/parity/fixtures/ml_images.parquet")
media_ids = cs_media.ids_of(media, df)
MAX_SIDE = 512
warnings = []
status, info, feats, hashes, thumbs, rgbs = [], [], [], [], [], []
for i, p in enumerate(df[PATH].tolist()):
path = fx.resolve(p, FOLDER, DATA_DIR)
if path is None:
status.append("no path")
info.append({"row": i, "path": None})
continue
r = fx.read(path)
if r["status"] == "unsupported" and fxt.is_tiff(path):
r = fxt.read(path, r, media, media_ids[i] if media_ids else None) # TIFF: decoded by the host
status.append(r["status"])
rec = {"row": i, "path": path, "file": os.path.basename(path), "format": r.get("format"), "bytes": r.get("bytes"), "md5": r.get("md5")}
if r["status"] == "ok":
small = fx.fit(r["rgb"], MAX_SIDE)
m = fx.measures(small)
h = fx.phash(fx.luma(small))
rec.update(width=r["width"], height=r["height"], alpha=r["alpha"], phash=fx.hex_bits(h), **m,
**(fxt.exif(path) if r["format"] == "TIFF" else fx.exif(path)))
feats.append([m["brightness"], m["contrast"], m["mean_r"], m["mean_g"], m["mean_b"], m["colourfulness"], m["saturation"],
np.log1p(m["sharpness"]) if m["sharpness"] == m["sharpness"] else np.nan, m["entropy"], *fx.thumb(small)])
hashes.append(h)
rgbs.append(r["rgb"] if False else None)
info.append(rec)
ok = [k for k, s in enumerate(status) if s == "ok"]
if not ok:
if not status:
cs.cs_error("CS_E_NO_ROWS")
if all(s == "no path" for s in status):
cs.cs_error("CS_E_ALL_MISSING", column=PATH)
# None of the listed files could be read (missing, not PNG, JPEG or TIFF, or not decodable).
cs.cs_error("CS_E_INVALID_VALUES", column=PATH, requirement="a PNG, JPEG or TIFF file that exists",
count=sum(1 for s in status if s != "no path"))
for s, what in (("no path", "have no path"), ("missing", "point to files that do not exist"), ("unsupported", "are not PNG, JPEG or a readable kind of TIFF"), ("unreadable", "could not be decoded")):
k = status.count(s)
if k:
warnings.append(f"{k} rows {what} and are left out.")
img = [info[k] for k in ok]
# %% Duplicates: perceptual-hash groups and identical files
DUP = 6
groups = fx.dup_groups(hashes, DUP)
seen_md5, exact = set(), []
for rec in img:
exact.append(rec["md5"] in seen_md5)
seen_md5.add(rec["md5"])
first_in_group = {}
for j, g in enumerate(groups):
if g and g not in first_in_group:
first_in_group[g] = j
# %% Map: PCA of the classic features
F = np.array(feats, dtype=float)
col_mean = np.nanmean(F, axis=0)
F = np.where(np.isnan(F), col_mean, F)
EMBED_LABEL = "Classic features"
Y, map_shares = fx.classic_map(F) if len(F) >= 2 else (np.zeros((len(F), 2)), [float("nan"), float("nan")])
# %% Flags
DARK, BRIGHT, BLUR = 0.15, 0.85, 100
flags = []
for j, rec in enumerate(img):
if exact[j] or (groups[j] and first_in_group[groups[j]] != j):
f = "Duplicate"
elif rec["brightness"] < DARK:
f = "Dark"
elif rec["brightness"] > BRIGHT:
f = "Bright"
elif rec["sharpness"] == rec["sharpness"] and rec["sharpness"] < BLUR:
f = "Blurry" # after exposure: very dark or bright frames have little detail anyway
else:
f = "OK"
flags.append(f)
rec.update(dup_group=int(groups[j]), exact_duplicate=bool(exact[j]), flag=f, map_x=float(Y[j, 0]), map_y=float(Y[j, 1]))
# %% Artifacts
out = csml.out_dir("target/academy-parity/run-8142/describe.images/folder_defaults/out-python")
cols = ["row", "path", "file", "format", "bytes", "md5", "width", "height", "alpha", "brightness", "contrast", "mean_r", "mean_g", "mean_b",
"colourfulness", "saturation", "sharpness", "entropy", "clipped_dark", "clipped_bright", "phash", "dup_group", "exact_duplicate", "flag",
"make", "model", "datetime", "orientation", "exposure", "fnumber", "iso", "focal", "gps", "map_x", "map_y"]
art = pd.DataFrame([{c: rec.get(c) for c in cols} for rec in img], columns=cols)
for c in ("make", "model", "datetime", "phash", "flag", "format", "file", "path", "md5"):
art[c] = art[c].astype("string")
for c in ("orientation", "iso"):
art[c] = pd.array([None if pd.isna(v) else int(v) for v in art[c]], dtype="Int64")
for c in ("exposure", "fnumber", "focal"):
art[c] = pd.to_numeric(art[c], errors="coerce").astype("float64")
art["gps"] = art["gps"].astype("boolean")
art.to_parquet(os.path.join(out, "images.parquet"), index=False)
# %% Result
W = np.array([r["width"] for r in img], dtype=float)
H = np.array([r["height"] for r in img], dtype=float)
B = np.array([r["brightness"] for r in img])
S = np.array([r["sharpness"] for r in img])
values = {
"n_rows": len(df), "n_images": len(img), "n_no_path": status.count("no path"), "n_missing": status.count("missing"),
"n_unsupported": status.count("unsupported"), "n_unreadable": status.count("unreadable"),
"n_png": sum(r["format"] == "PNG" for r in img), "n_jpeg": sum(r["format"] == "JPEG" for r in img),
"n_alpha": sum(bool(r["alpha"]) for r in img), "bytes_total": int(sum(r["bytes"] for r in img)),
"width_min": float(W.min()), "width_median": float(np.median(W)), "width_max": float(W.max()),
"height_min": float(H.min()), "height_median": float(np.median(H)), "height_max": float(H.max()),
"megapixels_median": float(np.median(W * H) / 1e6), "aspect_median": float(np.median(W / H)),
"share_portrait": float(np.mean(H > W)), "n_sizes": len({(int(w), int(h)) for w, h in zip(W, H)}),
"brightness_mean": float(B.mean()), "brightness_sd": float(B.std(ddof=1)) if len(B) > 1 else None,
"contrast_mean": float(np.mean([r["contrast"] for r in img])),
"colourfulness_mean": float(np.mean([r["colourfulness"] for r in img])),
"saturation_mean": float(np.mean([r["saturation"] for r in img])),
"sharpness_median": float(np.nanmedian(S)) if np.isfinite(S).any() else None,
"entropy_mean": float(np.mean([r["entropy"] for r in img])),
"n_dark": flags.count("Dark"), "n_bright": flags.count("Bright"), "n_blurry": flags.count("Blurry"),
"n_exif": sum(1 for r in img if r.get("make") or r.get("model") or r.get("datetime")),
"n_gps": sum(1 for r in img if r.get("gps")),
"n_dup_groups": int(groups.max()) if len(groups) else 0, "n_in_dup_groups": int(np.sum(groups > 0)),
"n_exact_dups": int(sum(exact)),
"map_share_1": map_shares[0], "map_share_2": map_shares[1], "embedding": EMBED_LABEL,
}
n_tiff = sum(r["format"] == "TIFF" for r in img)
if n_tiff:
values["n_tiff"] = n_tiff # only when TIFF files were read, so results without them keep their keys
cams: dict[str, int] = {}
for r in img:
if r.get("make") or r.get("model"):
key = " ".join(x for x in (r.get("make"), r.get("model")) if x)
cams[key] = cams.get(key, 0) + 1
for key, k in sorted(cams.items()):
values[f"camera[{key}]"] = k
assumptions = [
{"key": "formats", "label": "PNG, JPEG and TIFF", "status": "warn" if values["n_unsupported"] else "pass",
"detail": f"{values['n_unsupported']} listed files are not PNG, JPEG or a readable kind of TIFF." if values["n_unsupported"] else "Every readable file is PNG, JPEG or TIFF."},
{"key": "blur_scale", "label": "Sharpness depends on size and content", "status": "info",
"detail": f"Sharpness is measured at most {MAX_SIDE} pixels on the long side; plain images score low without being blurred."},
{"key": "personal_data", "label": "Personal data in metadata", "status": "warn" if values["n_gps"] else "pass",
"detail": f"{values['n_gps']} images carry GPS location data (coordinates are not read)." if values["n_gps"] else "No image carries GPS data."},
]
flagged = [r for r in img if r["flag"] != "OK"][:50]
tables = [{
"key": "flagged", "title": "Flagged images",
"columns": [{"key": "file", "label": "File"}, {"key": "flag", "label": "Flag"}, {"key": "brightness", "label": "Brightness", "type": "number"},
{"key": "sharpness", "label": "Sharpness", "type": "number"}, {"key": "dup_group", "label": "Duplicate group", "type": "integer"}],
"rows": [{k: r.get(k) for k in ("file", "flag", "brightness", "sharpness", "dup_group")} for r in flagged],
}]
if cams:
tables.append({"key": "cameras", "title": "Cameras (EXIF)", "columns": [{"key": "camera", "label": "Make and model"}, {"key": "images", "label": "Images", "type": "integer"}],
"rows": [{"camera": key, "images": k} for key, k in sorted(cams.items())]})
FLAG_LEVELS = ["OK", "Dark", "Bright", "Blurry", "Duplicate"]
if LABEL is not None:
lab = df[LABEL].iloc[[r["row"] for r in img]]
groups_col = ["(missing)" if pd.isna(v) else str(v) for v in lab]
group_title = LABEL
else:
groups_col, group_title = flags, "Flag"
charts = [
cs.chart("quality", "image-quality", "Brightness and sharpness", {
"brightness": cs.col("Brightness (0–1)", B, "numeric"),
"sharpness": cs.col("Sharpness (variance of the Laplacian)", np.nan_to_num(S, nan=0.0), "numeric"),
"flag": cs.col("Flag", flags, "categorical", FLAG_LEVELS),
"label": cs.col("File", [r["file"] for r in img], "categorical"),
}, controls={"dark": DARK, "bright": BRIGHT, "blur": BLUR}),
cs.chart("sizes", "image-sizes", "Pixel sizes", {
"width": cs.col("Width (px)", W, "numeric"),
"height": cs.col("Height (px)", H, "numeric"),
"group": cs.col("Format", [r["format"] for r in img], "categorical"),
"label": cs.col("File", [r["file"] for r in img], "categorical"),
}),
cs.chart("map", "cluster-scatter", f"Images by similarity ({EMBED_LABEL.lower()})", {
"x": cs.col("PC 1", Y[:, 0], "numeric"),
"y": cs.col("PC 2", Y[:, 1], "numeric"),
"cluster": cs.col(group_title, groups_col, "categorical"),
"label": cs.col("File", [r["file"] for r in img], "categorical"),
}),
]
cs.publish({
"title": "Image collection profile (size, color, sharpness, duplicates)",
"engine": cs.engine_info("pillow", "numpy", "pandas"),
"n": len(img),
"summary": f"{len(img)} images: median {int(values['width_median'])} × {int(values['height_median'])} px; {values['n_dark']} dark, {values['n_bright']} bright, {values['n_blurry']} blurry, {values['n_in_dup_groups']} in near-duplicate groups.",
"statistics": [
{"key": "n_images", "label": "Images read", "value": len(img)},
{"key": "brightness_mean", "label": "Mean brightness", "value": values["brightness_mean"]},
{"key": "sharpness_median", "label": "Median sharpness", "value": values["sharpness_median"]},
{"key": "n_in_dup_groups", "label": "In duplicate groups", "value": values["n_in_dup_groups"]},
],
"tables": tables,
"assumptions": assumptions,
"charts": charts,
"values": values,
"warnings": warnings,
"artifacts": [{"key": "images", "path": os.path.join(out, "images.parquet"), "format": "parquet"}],
})
The exact script CodeSplash ran for example “Folder defaults” · R version 4.5.1 (2025-06-13)
# Image collection profile (size, color, sharpness, duplicates)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method describe.images 1.1.0 · spec bcdfced43aa2ed60
# Dataset: ml_images (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr)
# %% Images listed in the path column
PATH <- "path"
LABEL <- NULL
FOLDER <- path.expand("")
DATA_DIR <- dirname(normalizePath("tests/parity/fixtures/ml_images.parquet", mustWork = FALSE))
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/ml_images.parquet", col_select = c(PATH, LABEL)))
# %% Media files (image column path)
# In the app the files were decoded once into float32 arrays (media.json in the run folder). Elsewhere they are
# decoded here the same way: PNG and WAV give the app's values; JPEG, MP3 and other lossy files can differ slightly.
media <- cs_media_setup(jsonlite::fromJSON("{\"ids_column\":\"media_id\",\"kind\":\"image\",\"path_column\":\"path\",\"role\":\"image\",\"transform\":{\"filter\":\"triangle\",\"fit\":\"original\",\"formats\":[\"tiff\"],\"mode\":\"rgb\",\"normalize\":\"none\",\"orientation\":\"stored\",\"size\":[224,224]}}", simplifyVector = FALSE), "target/academy-parity/run-8142/describe.images/folder_defaults/out-r", df,
"tests/parity/fixtures/ml_images.parquet")
media_ids <- cs_media_ids(media, df)
MAX_SIDE <- 512
warnings <- list()
status <- character(0); info <- list(); feats <- list(); hashes <- list()
nz <- function(x) !is.null(x) && !is.na(x) && nzchar(x)
for (i in seq_len(nrow(df))) {
path <- cs_img_resolve(as.character(df[[PATH]][i]), FOLDER, DATA_DIR)
if (is.na(path)) { status <- c(status, "no path"); info[[i]] <- list(row = i - 1L); next }
r <- cs_img_read(path)
if (r$status == "unsupported" && cs_img_is_tiff(path)) # TIFF: decoded by the host
r <- cs_img_tiff_read(path, r, media, if (is.null(media_ids)) NA_character_ else media_ids[i])
status <- c(status, r$status)
rec <- list(row = i - 1L, path = path, file = basename(path), format = r$format, bytes = r$bytes, md5 = r$md5)
if (r$status == "ok") {
small <- cs_img_fit(r$rgb, MAX_SIDE)
m <- cs_img_measures(small)
h <- cs_img_phash(cs_img_luma(small))
rec <- c(rec, list(width = r$width, height = r$height, alpha = r$alpha, phash = cs_img_hex(h)), m,
if (identical(r$format, "TIFF")) cs_img_tiff_exif(path) else cs_img_exif(path))
feats[[length(feats) + 1]] <- c(m$brightness, m$contrast, m$mean_r, m$mean_g, m$mean_b, m$colourfulness, m$saturation,
if (is.nan(m$sharpness)) NA else log1p(m$sharpness), m$entropy, cs_img_thumb(small))
hashes[[length(hashes) + 1]] <- h
}
info[[i]] <- rec
}
ok <- which(status == "ok")
if (!length(ok)) {
if (!length(status)) cs_error("CS_E_NO_ROWS")
if (all(status == "no path")) cs_error("CS_E_ALL_MISSING", column = PATH)
# None of the listed files could be read (missing, not PNG, JPEG or TIFF, or not decodable).
cs_error("CS_E_INVALID_VALUES", column = PATH, requirement = "a PNG, JPEG or TIFF file that exists",
count = sum(status != "no path"))
}
for (pair in list(c("no path", "have no path"), c("missing", "point to files that do not exist"), c("unsupported", "are not PNG, JPEG or a readable kind of TIFF"), c("unreadable", "could not be decoded"))) {
k <- sum(status == pair[1])
if (k) warnings <- c(warnings, sprintf("%d rows %s and are left out.", k, pair[2]))
}
img <- info[ok]
# %% Duplicates: perceptual-hash groups and identical files
DUP <- 6
groups <- cs_img_dup_groups(hashes, DUP)
md5s <- vapply(img, function(r) r$md5, "")
exact <- duplicated(md5s)
first_in_group <- vapply(seq_along(groups), function(j) groups[j] > 0 && match(groups[j], groups) == j, TRUE)
# %% Map: PCA of the classic features
F <- do.call(rbind, feats)
for (c in seq_len(ncol(F))) F[is.na(F[, c]), c] <- mean(F[, c], na.rm = TRUE)
EMBED_LABEL <- "Classic features"
mp <- if (nrow(F) >= 2) cs_img_classic_map(F) else list(Y = matrix(0, nrow(F), 2), shares = c(NaN, NaN))
Y <- mp$Y
# %% Flags
DARK <- 0.15; BRIGHT <- 0.85; BLUR <- 100
flags <- vapply(seq_along(img), function(j) {
r <- img[[j]]
if (exact[j] || (groups[j] > 0 && !first_in_group[j])) "Duplicate"
else if (r$brightness < DARK) "Dark"
else if (r$brightness > BRIGHT) "Bright"
else if (!is.nan(r$sharpness) && r$sharpness < BLUR) "Blurry" # after exposure: very dark or bright frames have little detail anyway
else "OK"
}, "")
for (j in seq_along(img)) img[[j]] <- c(img[[j]], list(dup_group = groups[j], exact_duplicate = exact[j], flag = flags[j], map_x = Y[j, 1], map_y = Y[j, 2]))
# %% Artifacts
out <- cs_ml_out_dir("target/academy-parity/run-8142/describe.images/folder_defaults/out-r")
get <- function(field, type) {
v <- lapply(img, function(r) if (is.null(r[[field]])) NA else r[[field]])
switch(type, chr = vapply(v, function(x) if (is.na(x)) NA_character_ else as.character(x), ""),
num = vapply(v, function(x) as.numeric(x), 0), int = vapply(v, function(x) as.integer(x), 0L),
lgl = vapply(v, function(x) as.logical(x), TRUE))
}
art <- data.frame(row = get("row", "int"), path = get("path", "chr"), file = get("file", "chr"), format = get("format", "chr"),
bytes = get("bytes", "num"), md5 = get("md5", "chr"), width = get("width", "int"), height = get("height", "int"),
alpha = get("alpha", "lgl"), stringsAsFactors = FALSE)
for (f in c("brightness", "contrast", "mean_r", "mean_g", "mean_b", "colourfulness", "saturation", "sharpness", "entropy", "clipped_dark", "clipped_bright")) art[[f]] <- get(f, "num")
art$phash <- get("phash", "chr"); art$dup_group <- get("dup_group", "int"); art$exact_duplicate <- get("exact_duplicate", "lgl"); art$flag <- get("flag", "chr")
art$make <- get("make", "chr"); art$model <- get("model", "chr"); art$datetime <- get("datetime", "chr")
art$orientation <- get("orientation", "int"); art$exposure <- get("exposure", "num"); art$fnumber <- get("fnumber", "num")
art$iso <- get("iso", "int"); art$focal <- get("focal", "num"); art$gps <- get("gps", "lgl"); art$map_x <- get("map_x", "num"); art$map_y <- get("map_y", "num")
nanoparquet::write_parquet(art, file.path(out, "images.parquet"))
# %% Result
W <- as.numeric(art$width); H <- as.numeric(art$height); B <- art$brightness; S <- art$sharpness
values <- list(
n_rows = nrow(df), n_images = length(img), n_no_path = sum(status == "no path"), n_missing = sum(status == "missing"),
n_unsupported = sum(status == "unsupported"), n_unreadable = sum(status == "unreadable"),
n_png = sum(art$format == "PNG"), n_jpeg = sum(art$format == "JPEG"), n_alpha = sum(art$alpha), bytes_total = sum(art$bytes),
width_min = min(W), width_median = stats::median(W), width_max = max(W),
height_min = min(H), height_median = stats::median(H), height_max = max(H),
megapixels_median = stats::median(W * H) / 1e6, aspect_median = stats::median(W / H),
share_portrait = mean(H > W), n_sizes = nrow(unique(data.frame(W, H))),
brightness_mean = mean(B), brightness_sd = if (length(B) > 1) stats::sd(B) else NULL,
contrast_mean = mean(art$contrast), colourfulness_mean = mean(art$colourfulness), saturation_mean = mean(art$saturation),
sharpness_median = if (any(is.finite(S))) stats::median(S[is.finite(S)]) else NULL,
entropy_mean = mean(art$entropy),
n_dark = sum(flags == "Dark"), n_bright = sum(flags == "Bright"), n_blurry = sum(flags == "Blurry"),
n_exif = sum(vapply(img, function(r) nz(r$make) || nz(r$model) || nz(r$datetime), TRUE)),
n_gps = sum(vapply(img, function(r) isTRUE(r$gps), TRUE)),
n_dup_groups = if (length(groups)) max(groups) else 0L, n_in_dup_groups = sum(groups > 0), n_exact_dups = sum(exact),
map_share_1 = mp$shares[1], map_share_2 = mp$shares[2], embedding = EMBED_LABEL
)
n_tiff <- sum(art$format == "TIFF", na.rm = TRUE)
if (n_tiff > 0) values$n_tiff <- n_tiff # only when TIFF files were read, so results without them keep their keys
cam_names <- vapply(img, function(r) {
parts <- c(if (nz(r$make)) r$make, if (nz(r$model)) r$model)
if (length(parts)) paste(parts, collapse = " ") else NA_character_
}, "")
cams <- table(cam_names[!is.na(cam_names)])
if (length(cams)) cams <- cams[order(names(cams), method = "radix")] # no camera data: an empty table has no names
for (key in names(cams)) values[[sprintf("camera[%s]", key)]] <- as.integer(cams[[key]])
assumptions <- list(
list(key = "formats", label = "PNG, JPEG and TIFF", status = if (values$n_unsupported) "warn" else "pass",
detail = if (values$n_unsupported) sprintf("%d listed files are not PNG, JPEG or a readable kind of TIFF.", values$n_unsupported) else "Every readable file is PNG, JPEG or TIFF."),
list(key = "blur_scale", label = "Sharpness depends on size and content", status = "info",
detail = sprintf("Sharpness is measured at most %d pixels on the long side; plain images score low without being blurred.", MAX_SIDE)),
list(key = "personal_data", label = "Personal data in metadata", status = if (values$n_gps) "warn" else "pass",
detail = if (values$n_gps) sprintf("%d images carry GPS location data (coordinates are not read).", values$n_gps) else "No image carries GPS data.")
)
flagged <- utils::head(which(flags != "OK"), 50)
tables <- list(list(
key = "flagged", title = "Flagged images",
columns = list(list(key = "file", label = "File"), list(key = "flag", label = "Flag"), list(key = "brightness", label = "Brightness", type = "number"),
list(key = "sharpness", label = "Sharpness", type = "number"), list(key = "dup_group", label = "Duplicate group", type = "integer")),
rows = lapply(flagged, function(j) list(file = art$file[j], flag = flags[j], brightness = art$brightness[j], sharpness = art$sharpness[j], dup_group = art$dup_group[j]))
))
if (length(cams)) tables[[2]] <- list(key = "cameras", title = "Cameras (EXIF)",
columns = list(list(key = "camera", label = "Make and model"), list(key = "images", label = "Images", type = "integer")),
rows = lapply(names(cams), function(k) list(camera = k, images = as.integer(cams[[k]]))))
FLAG_LEVELS <- c("OK", "Dark", "Bright", "Blurry", "Duplicate")
if (!is.null(LABEL)) {
lab <- df[[LABEL]][art$row + 1L]
groups_col <- ifelse(is.na(lab), "(missing)", as.character(lab)); group_title <- LABEL
} else {
groups_col <- flags; group_title <- "Flag"
}
charts <- list(
cs_chart("quality", "image-quality", "Brightness and sharpness", list(
brightness = cs_col("Brightness (0–1)", B, "numeric"),
sharpness = cs_col("Sharpness (variance of the Laplacian)", ifelse(is.nan(S), 0, S), "numeric"),
flag = cs_col("Flag", flags, "categorical", FLAG_LEVELS),
label = cs_col("File", art$file, "categorical")
), controls = list(dark = DARK, bright = BRIGHT, blur = BLUR)),
cs_chart("sizes", "image-sizes", "Pixel sizes", list(
width = cs_col("Width (px)", W, "numeric"), height = cs_col("Height (px)", H, "numeric"),
group = cs_col("Format", art$format, "categorical"), label = cs_col("File", art$file, "categorical")
)),
cs_chart("map", "cluster-scatter", sprintf("Images by similarity (%s)", tolower(EMBED_LABEL)), list(
x = cs_col("PC 1", Y[, 1], "numeric"), y = cs_col("PC 2", Y[, 2], "numeric"),
cluster = cs_col(group_title, groups_col, "categorical"), label = cs_col("File", art$file, "categorical")
))
)
cs_publish(list(
title = "Image collection profile (size, color, sharpness, duplicates)",
engine = cs_engine_info("png", "jpeg", "codesplashr", "nanoparquet"),
n = length(img),
summary = sprintf("%d images: median %d × %d px; %d dark, %d bright, %d blurry, %d in near-duplicate groups.",
length(img), as.integer(values$width_median), as.integer(values$height_median), values$n_dark, values$n_bright, values$n_blurry, values$n_in_dup_groups),
statistics = list(
list(key = "n_images", label = "Images read", value = length(img)),
list(key = "brightness_mean", label = "Mean brightness", value = values$brightness_mean),
list(key = "sharpness_median", label = "Median sharpness", value = values$sharpness_median),
list(key = "n_in_dup_groups", label = "In duplicate groups", value = values$n_in_dup_groups)
),
tables = tables,
assumptions = assumptions,
charts = charts,
values = values,
warnings = warnings,
artifacts = list(list(key = "images", path = file.path(out, "images.parquet"), format = "parquet"))
))
Sources
- Pech-Pacheco JL, Cristóbal G, Chamorro-Martínez J, Fernández-Valdivia J (2000). Diatom autofocusing in brightfield microscopy: a comparative study. ICPR 2000, 314–317.
- Hasler D, Süsstrunk S (2003). Measuring colourfulness in natural images. Proc. SPIE 5007, Human Vision and Electronic Imaging VIII.
- Peli E (1990). Contrast in complex images. JOSA A 7(10):2032–2040.
- Zauner C (2010). Implementation and benchmarking of perceptual image hash functions. Master's thesis, Upper Austria University of Applied Sciences.
- ITU-R Recommendation BT.601-7 (2011). Studio encoding parameters of digital television.
- JEITA CP-3451 (2019). Exchangeable image file format for digital still cameras: Exif version 2.32.
- Howard A, Sandler M, Chu G, et al. (2019). Searching for MobileNetV3. ICCV 2019, 1314–1324.
- Adobe Systems (1992). TIFF Revision 6.0. Adobe Developers Association.
From the CodeSplash method registry · describe.images v1.1.0.