# Check Whether an AI Image Edit Changed a Protected Region

> Compare a protected label or detail pixel for pixel in two aligned RGB PNGs and locate unexpected changes with a small Pillow script.

Canonical article: https://modelrovia.com/guides/verify-ai-image-edit-region/
Author: Modelrovia Editorial
Published: 2026-11-11
Updated: 2026-11-11

## Key takeaway

Compare an aligned protected rectangle in opaque PNGs and locate changed pixels.

If an image edit should change only the background, check the label pixels before approving the result. On our synthetic product fixture, a background-only change passed. A second variant with a three-by-three pixel mark on the label failed and reported the changed rectangle. Pillow's channel difference operation provides the pixel comparison. [Pillow ImageChops reference](https://pillow.readthedocs.io/en/stable/reference/ImageChops.html)

## Check a protected rectangle

Save the [comparison script](/examples/check-protected-image-region.py), [original](/examples/protected-region-original.png), [background edit](/examples/protected-region-background-edit.png) and [label change](/examples/protected-region-label-change.png). The images were constructed as test inputs. They represent a strict approval condition you can apply to your own AI-edited exports.

~~~sh
python -m pip install pillow==13.0.0
python check-protected-image-region.py protected-region-original.png protected-region-background-edit.png 84 60 157 91
python check-protected-image-region.py protected-region-original.png protected-region-label-change.png 84 60 157 91
~~~

The first run reports a match. The second reports changed bounds of (145, 70, 148, 73) and exits with status 1. Both were tested on November 11, 2026. Coordinates use the source canvas with the origin at the upper-left. Right and bottom are exclusive, so the detected change spans x=145 through 147 and y=70 through 72.

## Interpret the result against your brief

Choose the rectangle on the original image. Include the detail that must stay fixed, such as the entire printed label. A tight rectangle around one word misses other altered details. Use multiple checks if several regions matter.

The comparison expects same-size, aligned, single-frame opaque RGB PNGs, with normal orientation and no embedded ICC profile. An image that was resized, repositioned or saved through a lossy export can produce pixel changes even if it looks similar. If your workflow calls for resizing, establish a new aligned baseline or use a visual approval step instead of expecting exact equality across different canvases.

## Review the rest of the edit

A passing label check says that the pixels in the selected rectangle match. Inspect the rest of the product, especially its silhouette, edges and shadow, against the original. For edits where label fidelity is mandatory, one option is to keep the approved product as its own layer and apply the new background behind it. Export the composite and rerun the protected-region check.

The companion [Seedream editing guide](/guides/seedream-image-editing/) explains how to define the change and the details to protect in the brief. Use this script after export when the deliverable calls for exact preservation of those pixels.

## Sources & references

- [Pillow image difference documentation](https://pillow.readthedocs.io/en/stable/reference/ImageChops.html)

[Editorial standards](https://modelrovia.com/methodology/)
