Esacode

Docs / Blocks / Processing

Image quality check

Opens every image and measures its size, sharpness, exposure and contrast; flags broken, small, blurred, dark, bright or flat images with the reason.

Runs on a worker (Python) Processing Version 1.1 Code you can open and adapt

How it works

Each image is measured at the same scale: sharpness is the variance of the Laplacian (low = blurred), brightness and contrast come from the grey levels, and the share of nearly black or nearly white pixels shows bad exposure.

Sharpness is judged against the images of the same folder: an image under Blurred (%) of its folder's typical sharpness is flagged blurred, so sharp-edged and soft-textured classes are each judged fairly. Nothing is removed here: the table goes to Curate and split (which removes the flagged images) or to a Table and a Chart. Runs on any worker, a few hundred images per second.

Inputs

InputTakesWhat it is
Images
images
Files
jpg, jpeg, png, webp, bmp, tif
Images, in folders (the folder is the label) Takes several connections.

Outputs

OutputGivesWhat it is
Flags
table
Table
csv
quality.csv: one row per image (path, label, width, height, sharpness, brightness, contrast, dark_pct, bright_pct, flag, reason); flag is empty when the image is fine
Live telemetry
telemetry
Live telemetryWhat the block sends while it runs, for views such as Chart or 3D view.

Settings

SettingDefaultWhat it does
Smallest side (px)
min_side
0 Images smaller than this on their shorter side are flagged; 0: no limit. Many datasets have small photos (FruitNet: often under 224 px): set it to what your model needs
From 0
Blurred (%)
blur
25 Flagged under this share of the folder's typical sharpness; 0: no check
From 0 to 100
Too dark (% black pixels)
dark
60 0: no check
From 0 to 100
Too bright (% white pixels)
bright
60 0: no check
From 0 to 100
Least contrast
contrast
8 Standard deviation of the grey levels; 0: no check
From 0

Where it runs

On one of your computers with the EsaSim worker: Any worker. The worker installs the Python packages it needs when they are missing: numpy</code>, <code>pillow.

In its code, settings are ctx.params["key"], inputs ctx.inputs["id"] and outputs ctx.output("id", "name.ext"); see Custom blocks.

More in Processing