MaskFlow: Precise, Consistent and Seamless Regional Image Editing

Rui Xu, Yang Yong, Shunzi Yang, Ruihao Gong, Chengtao LvarXiv 2026

TL;DR

MaskFlow is a novel training framework designed to bring precise spatial control, flawless background preservation, and seamless boundary transitions to regional image editing. By embedding user-defined masks directly into the probability path of flow-matching models and introducing a step-by-step Soft-Poisson de-seaming module, it eliminates the semantic drift and visible boundary artifacts that plague current editing methods.

What Problem Does This Paper Address?

Regional image editing requires modifying a specific area of an image based on user instructions while keeping the rest of the scene completely untouched. Current approaches generally fall into two categories: instruction-based (text-only) and mask-reference-based.

Text instructions frequently suffer from spatial ambiguity, especially in complex layouts like infographics where multiple similar objects exist. While mask-based methods resolve this localization issue by letting users explicitly draw an edit zone, they face a different hurdle: they typically treat the mask as a mere input condition rather than a hard constraint on the generation process. Because the foreground edit and the background context follow independent generation trajectories, the final image often suffers from stylistic drift or ugly, visible seams along the mask boundaries.

Qualitative comparison showing boundary seams and incorrect localization in baselines.

Methods

MaskFlow tackles these issues through three core architectural innovations built on top of flow-matching models:

  1. Mask-Integrated Probability Path: Instead of feeding the mask into the model as an auxiliary feature map, MaskFlow incorporates it directly into the flow-matching probability path equations. This mathematically forces the unmasked background to strictly adhere to the source image's trajectory throughout the entire denoising process.
  2. Adaptive Mask Loss: To ensure the model handles edits of all shapes and sizes equally well, the authors introduce a mask-aware training objective. This objective scales the loss dynamically based on the ratio of the masked area to the total image size, preventing massive edits or tiny touch-ups from dominating the training gradients.
  3. Soft-Poisson De-Seaming Module: Inspired by classical gradient-domain Poisson image editing, this module operates during the sampling phase. At each denoising step, it refines the predicted vector field by solving a unified gradient-domain objective. By utilizing a blurred "soft mask," it smoothly blends the gradients and features of the generated foreground with the preserved background context, eliminating harsh boundary lines before they can manifest in the final pixels.
Probability paths for Soft-Poisson de-seaming vs conventional flow-matching.

Datasets

To train and evaluate MaskFlow, the authors introduced MEData (Mask-based Image Editing Dataset). It consists of approximately 10,000 high-quality image pairs covering both natural scenes and complex infographic designs.

The dataset was constructed using a three-stage synthesis pipeline:

  • Object Detection: A vision-language model identifies primary objects in a source image.
  • Prompt Generation: The system generates editing instructions that intentionally omit explicit spatial descriptions (e.g., "replace the text in the masked area" instead of "replace the text at the bottom left"), forcing the model to rely entirely on the mask for localization during training.
  • Image Generation & Segmentation: A generative model synthesizes the target image, and the Segment Anything Model (SAM)—refined by human annotators—generates realistic, arbitrary mask shapes.

Key Insights and Ideas

  • Masks as Hard Constraints: Treating a mask as a boundary constraint on the generative trajectory rather than just an extra conditioning feature is the key to achieving perfect background preservation.
  • Generative-Informed Poisson Blending: Classical Poisson editing is typically applied as a post-processing step on finished images, which often leads to unnatural color bleeding if the underlying structures don't match. By applying a "Soft-Poisson" correction to the vector field at every single denoising step, MaskFlow allows boundary consistency to actively guide the generation process.
  • Forcing Mask Reliance via Prompt Engineering: Intentionally stripping spatial language from training prompts prevents the model from ignoring the mask and relying on textual shortcuts to find the edit zone.

Key Results

MaskFlow was evaluated against commercial heavyweights (Gemini 3 Flash, GPT Image 2) and specialized open-source regional editing models (RefineAnything, RegionE, SpotEdit) on the MEData benchmark:

  • Flawless Background Preservation: MaskFlow achieved a perfect 0.0000 score in both background Mean Squared Error (MSE) and background LPIPS, proving that unmasked regions remain entirely unaltered.
  • Superior Image Fidelity and Alignment: It achieved state-of-the-art global metrics, including a CLIP score of 0.9782 (semantic alignment), a DINO score of 0.9532 (structural consistency), and a Frechet Inception Distance (FID) of 19.90 (image quality).
  • Infographic Mastery: Qualitative tests on dense infographic layouts demonstrated that MaskFlow successfully replaces text and icons within complex graphical structures without corrupting adjacent text blocks or background textures.

Limitations and Future Work

Not explicitly discussed in the paper.

Summary updated

BibTeX
@misc{xu2026maskflow,
  author = {Rui Xu and Yang Yong and Shunzi Yang and Ruihao Gong and Chengtao Lv},
  title = {{MaskFlow: Precise, Consistent and Seamless Regional Image Editing}},
  year = {2026},
  eprint = {2608.06929},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2608.06929},
}
Figure