DEV Community

Voor AI
Voor AI

Posted on

How to Replace Text on a Sign With AI and Test Every Untouched Pixel

A real cafe sign before and after a single opening-hours replacement

The safest AI sign edit changes one quoted string and treats every other pixel as protected. Define the old text, new text, exact region, typography constraints, and a keep-list before generation; then compare the untouched area instead of judging only the new letters.

The current Voor Képszerkesztő AI editor selects GPT Image 2. Its Hungarian UI exposes a required image and prompt, presets including Felirat for text, size ratios, Advanced Settings, Public · watermarked visibility, and Generate. The inspected quote is 56 credits. Generate was not submitted.

Specify a one-region patch

Use quotes for the text contract:

Replace only “8–18” with “7–20” on the cafe chalkboard.
Keep “NYITVA”, the same chalk weight, spacing, baseline, perspective, board grain,
cafe interior, reflections, lighting, crop, and every non-target character unchanged.
Enter fullscreen mode Exit fullscreen mode

Short text is easier to validate. If the phrase is long, angled, or business-critical, generate the clean image and typeset the final copy deterministically instead.

Build an untargeted-region mask

The new glyphs are allowed to change. The rest of the frame is not. This minimal Python sketch creates a protected-region score when you supply a mask whose white pixels represent the edited text box:

from PIL import Image, ImageChops
import numpy as np

before = np.asarray(Image.open("before.png").convert("RGB"), dtype=np.int16)
after = np.asarray(Image.open("after.png").convert("RGB"), dtype=np.int16)
edit_mask = np.asarray(Image.open("text-mask.png").convert("L")) > 127

delta = np.abs(after - before).mean(axis=2)
protected_delta = delta[~edit_mask]
print({
    "protected_mean": float(protected_delta.mean()),
    "protected_p95": float(np.percentile(protected_delta, 95)),
})
Enter fullscreen mode Exit fullscreen mode

Compression and antialiasing mean the target is not literal zero. Compare against a threshold chosen for the file format and inspect every high-delta cluster.

The live text-edit preset beside the real source, result, and protected regions

Review type and scene separately

For type, check spelling, numerals, baseline, weight, perspective, and contrast. For the scene, inspect the board edge, reflections, shadows, nearby objects, light direction, and crop. A convincing “7–20” still fails if the model repaints the cafe.

Do not use generated text for safety signs, legal notices, prices, medication, or evidence without independent verification. Use only images you have the right to edit. Public-watermarked processing is inappropriate for confidential signage or private locations.

The release gate is one correct replacement plus a measured untouched region. Open the same image editor with that patch contract.

Top comments (1)

Collapse
 
topstar_ai profile image
Luis Cruz

Your approach to treating untouched areas as protected pixels is a clever way to ensure the integrity of the original image while making necessary edits. The use of a minimal Python sketch to calculate protected-region scores is particularly interesting; it could be enhanced by integrating more advanced image processing techniques, such as machine learning-based anomaly detection, to further refine the validation process. If you're exploring enhancements to this feature or need additional engineering support, I’d be happy to discuss a paid collaboration. What challenges have you faced in ensuring the accuracy of the untouched regions?