svgimage-quality
Image brightness and sharpness
Which images are too dark, washed out, blurry or duplicated?
How to read it
- Read each dot as one image: brightness across, sharpness up on a log scale.
- The shaded edges are too dark or too bright; dots under the dashed horizontal line are softer than the blur threshold.
- Colours give the method's flag, so you can open the flagged files in the table below the chart.
- Callout 1: The dark band: mean brightness below the threshold.
- Callout 2: The blur line: sharpness below it is flagged.
- Callout 3: The bright band: washed-out images.
Watch out
- Plain images (sky, walls, product shots on white) have little detail and score as blurry without being out of focus.
- Sharpness falls with image size, so compare images of similar size.
Defaults
- Dark below
- 0.15
- Brightness threshold drawn on the left; the method's own setting is sent with the result.
- Range 0 to 1, step 0.05
- Bright above
- 0.85
- Brightness threshold drawn on the right.
- Range 0 to 1, step 0.05
- Blurry below
- 100
- Sharpness threshold drawn as the horizontal line.
- Range 0 to 100,000, step 10
Pinned in the code
- Draws what the Python or R engine computed; the chart computes nothing statistical.
- Brightness is the mean ITU-R BT.601 luma on 0–1; sharpness is the variance of the 4-neighbour Laplacian, on a log10(1 + v) axis so small and large values both show.
- Flags follow the method's order: Duplicate first, then Dark, Bright and Blurry; an image gets one flag.
- Sharpness falls with image size and with plain content (sky, walls): a low value is a reason to look, not proof of blur.
# Image brightness and sharpness — Codesplash Chart Lab (recipe "image-quality")
# controls: dark=0.15, bright=0.85, blur=100
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]
# non-colour encodings per series (same table as the app: series are never told apart by colour alone)
SERIES_MARKERS = ["o", "s", "^", "D", "P", "*", "2", "v"]
df = pd.read_csv("image-quality-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["flag"] = pd.Categorical(df["flag"].astype("string"), categories=["OK", "Dark", "Bright", "Blurry", "Duplicate"])
_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"]) # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"]) # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
B = "brightness"
S = "sharpness"
FLAG = "flag"
LABEL = "file"
DARK, BRIGHT, BLUR = 0.15, 0.85, 100
FLAGS = ["OK", "Dark", "Bright", "Blurry", "Duplicate"]
d = df.dropna(subset=[B, S])
flags = d[FLAG].astype(str) if FLAG else pd.Series("OK", index=d.index)
order = [f for f in FLAGS if (flags == f).any()] + sorted(set(flags) - set(FLAGS))
fig, ax = plt.subplots(figsize=(7, 5))
if LABEL: # name the flagged files
for _, r in d[flags != "OK"].iterrows():
ax.annotate(str(r[LABEL]), (r[B], 1 + r[S]), xytext=(4, 3), textcoords="offset points", fontsize=7)
for i, f in enumerate(order):
m = flags == f
ax.scatter(d.loc[m, B], 1 + d.loc[m, S], s=24, color=GREY if f == "OK" else PALETTE[(i - ("OK" in order)) % len(PALETTE)], marker=SERIES_MARKERS[i % 8], label=f, alpha=0.8) # marker shape per flag, as in the app
ax.set_yscale("log") # the app plots log10(1 + sharpness)
for x in (DARK, BRIGHT):
ax.axvline(x, color=REF, linestyle="--", linewidth=0.9)
ax.axhline(1 + BLUR, color=REF, linestyle="--", linewidth=0.9)
ax.set_xlim(0, 1)
ax.set_xlabel("brightness (mean luma, 0–1)")
ax.set_ylabel("1 + sharpness (variance of the Laplacian)")
ax.legend(fontsize=8)
ax.set_title("Brightness and sharpness of each image")
plt.show()Needs pandas, numpy, matplotlib · reads image-quality-demo.csv · app theme from the optional codesplash helper
# Image brightness and sharpness — Codesplash Chart Lab (recipe "image-quality")
# controls: dark=0.15, bright=0.85, blur=100
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else px.colors.qualitative.Plotly
# non-colour encodings per series (same table as the app: series are never told apart by colour alone)
SERIES_MARKERS = ["circle", "square", "triangle-up", "diamond", "cross", "star", "y-up", "triangle-down"]
df = pd.read_csv("image-quality-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["flag"] = pd.Categorical(df["flag"].astype("string"), categories=["OK", "Dark", "Bright", "Blurry", "Duplicate"])
_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"]) # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"]) # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
B = "brightness"
S = "sharpness"
FLAG = "flag"
LABEL = "file"
DARK, BRIGHT, BLUR = 0.15, 0.85, 100
FLAGS = ["OK", "Dark", "Bright", "Blurry", "Duplicate"]
d = df.dropna(subset=[B, S])
flags = d[FLAG].astype(str) if FLAG else pd.Series("OK", index=d.index)
order = [f for f in FLAGS if (flags == f).any()] + sorted(set(flags) - set(FLAGS))
fig = go.Figure()
for i, f in enumerate(order):
m = flags == f
fig.add_scatter(x=d.loc[m, B], y=1 + d.loc[m, S], mode="markers", name=f, text=d.loc[m, LABEL] if LABEL else None,
marker=dict(size=8, color=GREY if f == "OK" else PALETTE[(i - ("OK" in order)) % len(PALETTE)], symbol=SERIES_MARKERS[i % 8], opacity=0.8)) # marker shape per flag
for x in (DARK, BRIGHT):
fig.add_vline(x=x, line_dash="dash", line_color=REF)
fig.add_hline(y=1 + BLUR, line_dash="dash", line_color=REF)
fig.update_yaxes(type="log", title="1 + sharpness (variance of the Laplacian)")
fig.update_xaxes(range=[0, 1], title="brightness (mean luma, 0–1)")
fig.update_layout(title="Brightness and sharpness of each image")
fig.show()Needs pandas, numpy, plotly · reads image-quality-demo.csv · app theme from the optional codesplash helper
# Image brightness and sharpness — Codesplash Chart Lab (recipe "image-quality")
# controls: dark=0.15, bright=0.85, blur=100
library(ggplot2)
has_cs <- isTRUE(requireNamespace("codesplashr", quietly = TRUE)) # optional: the app's chart theme
theme_cs <- if (has_cs) codesplashr::theme_codesplash(dark = FALSE) else theme_minimal()
cs_cat <- if (has_cs) codesplashr::cs_palette(dark = FALSE)$categorical else grDevices::palette.colors(8, "Okabe-Ito")
if (has_cs) update_geom_defaults("text", list(colour = codesplashr::cs_palette(dark = FALSE)$foreground))
# non-colour encodings per series (same table as the app: series are never told apart by colour alone)
cs_shapes <- c(16, 15, 17, 18, 3, 8, 4, 25)
df <- read.csv("image-quality-demo.csv", check.names = FALSE, stringsAsFactors = FALSE, na.strings = "") # empty cells are missing; Chart Lab → Code → Download demo CSV
df[["flag"]] <- factor(df[["flag"]], levels = c("OK", "Dark", "Bright", "Blurry", "Duplicate"))
df[["file"]] <- factor(df[["file"]])
tok <- if (has_cs) codesplashr::cs_palette(dark = FALSE) else list()
seq_ramp <- if (is.null(tok$sequential)) c("#eff6fd", "#1a469d") else tok$sequential # low → high
div_ramp <- if (is.null(tok$diverging)) c("#c13e2e", "#f3f5f8", "#0859ac") else tok$diverging # −, 0, +
ref_col <- if (is.null(tok$reference)) "#4e5661" else tok$reference
grey_col <- if (is.null(tok$dim)) "#ced1d6" else tok$dim
b_col <- "brightness"
s_col <- "sharpness"
flag_col <- "flag"
label_col <- "file"
dark <- 0.15; bright <- 0.85; blur <- 100
flags_all <- c("OK", "Dark", "Bright", "Blurry", "Duplicate")
d <- df[!is.na(df[[b_col]]) & !is.na(df[[s_col]]), ]
d$flag <- if (is.null(flag_col)) "OK" else as.character(d[[flag_col]])
lv <- c(intersect(flags_all, d$flag), setdiff(sort(unique(d$flag)), flags_all))
d$flag <- factor(d$flag, levels = lv)
cols <- setNames(ifelse(lv == "OK", grey_col, rep_len(cs_cat, length(lv))[pmax(1, seq_along(lv) - ("OK" %in% lv))]), lv)
p <- ggplot(d, aes(x = .data[[b_col]], y = 1 + .data[[s_col]], colour = flag, shape = flag)) + # marker shape per flag, as in the app
geom_vline(xintercept = c(dark, bright), colour = ref_col, linetype = "dashed") +
geom_hline(yintercept = 1 + blur, colour = ref_col, linetype = "dashed") +
geom_point(size = 2.2, alpha = 0.8) +
{ if (!is.null(label_col)) geom_text(data = d[d$flag != "OK", ], aes(label = .data[[label_col]]), size = 2.4, vjust = -0.9, show.legend = FALSE) } + # name the flagged files
scale_y_log10() + scale_x_continuous(limits = c(0, 1)) +
scale_colour_manual(values = cols) + scale_shape_manual(values = setNames(rep_len(cs_shapes, length(lv)), lv)) +
labs(x = "brightness (mean luma, 0–1)", y = "1 + sharpness (variance of the Laplacian)", colour = NULL, shape = NULL,
title = "Brightness and sharpness of each image") + theme_cs
print(p)Needs ggplot2 · reads image-quality-demo.csv · app theme from the optional codesplashr helper