# Spatially-Precise Video Editing with Reference Imitation: A Region-Aware Cross-Modal Framework
## 3 Materials and Methods
### Framework Overview  
As shown in Figure 1, the overall framework is mainly composed of three key steps: generating the canonical image, which serves as a stable reference representation with certain pre-defined characteristics (such as a standard scale, orientation, or color space relevant to the video content), conducting local editing on the canonical image, and leveraging the temporal deformation field to propagate the editing effect to the entire video. These three steps are intricately interconnected. The generation of the canonical image provides the basis for local editing, and the local editing in turn informs the creation of the temporal deformation field, which is then used to propagate the editing effect across the entire video, forming a seamless and complete video-editing process. This process can effectively handle various editing requirements in videos, especially the precise modification of local details.  
Our video reconstruction pipeline consists of multiple steps, taking a multi-resolution video sequence as input and outputting a synthesized video. First, features are extracted from video frames at different resolutions (Step 1), and spatio-temporal information is mapped to a normalized coordinate space using 3D hash encoding and deformation fields (Step 2). The Canonical Field is then utilized to compute the RGB colors of normalized pixels (Step 3). Next, the Local Editing Module is applied (Step 4): the generated canonical image serves as the source image, which undergoes masking and augmentation operations. By integrating provided reference images, the canonical image is enhanced and edited to enable precise style transfer and content adjustment. Finally, a high-quality reconstructed video is produced (Step 5).  
To enhance the clarity of the video editing workflow and elevate methodological transparency, we hereby present the following pseudocode. Algorithm 1 delineates the core operations of our framework, forging a seamless link between theoretical elaborations and procedural logic. It sequentially unfolds critical stages: commencing with input data loading, multi-scale feature extraction, and content deformation field computation, then advancing to canonical image generation, local editing application, and final frame reconstruction. Eachstep aligns with the technical specifics expounded in corresponding sections, offering readers a structured roadmap to thoroughly grasp the entire video editing pipeline.  
```
0: Input video frames \(V=\{I_{1},I_{2},...,I_{N}\}\), Reference image \(I_{ref}\)
0: Edited video frames \(V^{\prime}=\{I^{\prime}_{1},I^{\prime}_{2},...,I^{\prime}_{N}\}\)
1: Step 1: Load input video and reference image
2:\(V\leftarrow\) load_video(\"input_video.mp4\")
3:\(I_{ref}\leftarrow\) load_image(\"reference.jpg\")
4: Step 2: Extract Multi-Scale Features
5:for\(I_{i}\in V\)do
6:\(F_{i}\leftarrow\) extract_multiscale_features(\(I_{i}\))
7:endfor
8: Step 3: Compute Content Deformation Fields (CoDeF)
9:for\(F_{i}\in\{F_{1},...,F_{N}\}\)do
10:\(D_{i}\leftarrow\) compute_content_deformation(\(F_{i}\))
11:endfor
12: Step 4: Compute Canonical Image
13:\(I_{canonical}\leftarrow\) compute_canonical_image(\(\{D_{1},...,D_{N}\},I_{ref}\))
14: Step 5: Apply Local Editing
15:for\(F_{i}\in\{F_{1},...,F_{N}\}\)do
16:\(F^{\prime}_{i}\leftarrow\) apply_local_editing(\(F_{i},I_{canonical}\))
17:endfor
18: Step 6: Reconstruct Frames with Deformation Fields
19:for\(F^{\prime}_{i},D_{i}\in\{(F^{\prime}_{1},D_{1}),...,(F^{\prime}_{N},D_{N})\}\)do
20:\(I^{\prime}_{i}\leftarrow\) reconstruct_frame(\(F^{\prime}_{i},D_{i}\))
21:endfor
22: Step 7: Save the Edited Video
23:save_video(\(\{I^{\prime}_{1},I^{\prime}_{2},...,I^{\prime}_{N}\}\),\"edited_video.mp4\")
```  
**Algorithm 1** Video Editing Pipeline  
Figure 1: The overall architecture of our method. The entire process combines multi-resolution input, deformation field modeling, and feature alignment to achieve accurate spatio-temporal reconstruction and style transfer.