Instruments & Meters

When image cleanup changes mandatory text: a reference-first workflow

Mira KovalenkoOctober 25, 20265 min read8 views

At a glance

  • A small carton-image case shows why processed images with legally required text need an independent reference and two measurement principles.
  • A retailer's attempt to clean carton-back images with a generative model produced plausible but incorrect digits and punctuation, so the outputs were discarded. A deterministic processing chain, an early reference image, an OCR diff and a pixel-level ink check, plus independent review and backup checks, were used to keep published characters tied to photographed pixels.
A blank carton panel, a smartphone capture and a white reference sheet on a neutral workbench, with thin guide lines linking the photographed and cleaned views.

The case began with a narrow task: turn phone photographs of carton back panels into straight, clean images on a white background for online product pages. The panels carried legally required manufacturer and importer details, warning texts and contact information. The images could be improved, but the printed information had to remain identical. That distinction framed the entire exercise: the measurand was the printed text, not the appearance of the image.

Why a plausible image can still be wrong

A generative image model was first asked to preserve every printed character, number and symbol. Its output looked professional, with sharp print, even lighting and a clean background. Comparison with the source exposed changes that were easy to miss: 2801 became 2001, a phone number gained wrong digits, and commas and full stops were exchanged. These were not random visual artifacts. They were plausible substitutions, which is exactly why a quick visual inspection was a weak control. For mandatory information, plausibility is not a substitute for fidelity. The generated images were discarded and none was published.

A deterministic chain with traceable pixels

The replacement workflow was deterministic. Each carton face was rectified with a perspective transform based on four corner points. Uneven lighting was reduced by estimating the background illumination and dividing it out, followed by white balancing to a target tone. Denoising was kept gentle and edge-preserving. Text blocks were marked as protected regions, so their pixels passed through background clean-up unchanged. The processed face was then placed on a white background with a soft shadow. Nothing on the carton was redrawn or re-typeset; every character in the final panel came from photographed pixels.

That provenance mattered more than surface quality. A cleaned image can look sharper while moving farther from the evidence. By preserving the pixel source of each glyph, the workflow made the output accountable to the photograph rather than to a model's idea of what the text should look like.

The reference image and the measurement gate

For each image, the team retained a reference made from the same crop after rectification and the illumination and white-balance step only, before denoising or clean-up. Each processed carton face was compared with that reference before it was placed on the background. Two measurement principles were used. The first was an OCR diff: both images were upscaled and read by an open-source OCR engine with German and English language data, the word sequences were aligned, and every deviation was listed. The second was an ink check that did not depend on reading text. Pixels clearly darker than the carton background in the reference counted as print. If those pixels became light in the processed image and most of a connected group disappeared, the group was flagged as a lost character.

The gate also showed that classical processing is not automatically safe. A speckle filter turned 130 into 30 and removed colons. A threshold clean-up step erased the dot in a web address. Both stages were dropped. The underlying rule is simple: any step that decides what counts as noise can also decide that a full stop is noise. Classical filters therefore need the same scrutiny as AI tools.

OCR has its own uncertainty

An OCR diff is itself a measurement system, with its own error. On small print, the engine misread the reference as well, for example reading a 5 as an S. A raw OCR diff therefore reports disagreements that the processing did not cause. Taken at face value, those reports create false rejects. Ignored wholesale, they hide real changes and create false accepts. The useful analogy is a gauge study: before attributing variation to the part, the variation of the measurement system must be separated out. In this case, the OCR's misreads of the reference had to be distinguished from changes introduced by processing. A second, independent principle, the ink check, and a separate review step did that work.

Disagreement as a stop condition

The operating principle was to treat each disagreement as a stop to be resolved, not as a similarity score to be averaged away. A separate automated review, independent of the processing chain, checked the images in two rounds. In the first round, a composite image failed because one inserted line could not be verified reliably. The composite was removed and the genuine information block from the carton was used instead. Before any image was replaced, the previous state was backed up. After publication, the delivered files were downloaded and compared with the team's own copies. At reduced resolution, the mean absolute greyscale difference was well under one grey level. The published file was treated as the last link in the chain and checked like every step before it.

Practical rules and their limits

The case suggests a sequence for images that carry mandatory text. Define the measurand as the characters, not the appearance. Keep a separate reference from the earliest reliable processing step. Never compare an output only with itself. Use two measurement principles, such as an OCR text diff and a pixel-level ink check. Characterise the OCR's own errors on the reference before trusting its verdicts. Treat any disagreement as a stop. Test classical filters as rigorously as AI tools. Add an independent second review and remove what cannot be verified. Back up before every change and pixel-compare the published files. Improve the input with frontal, unwrapped, frame-filling photographs taken in daylight.

The boundaries matter. This was a small case outside factory inspection, and its results do not show that all generative models always corrupt text or that every image workflow needs the same gate. They do show a specific failure mode: a generative model can produce what text plausibly looks like rather than what was printed. They also show a specific control: an independent reference, two measurement principles and a stop rule make plausible errors visible before publication. For images where nothing has to be read, generative tools remain useful. For images that carry mandatory information, the case used classical processing plus a text comparison against the original.

Reported by Mira Kovalenko, Renewable Procurement and Lifecycle Editor.