---
title: Flat Patch Sampling Techniques
url: https://www.emergentmind.com/topics/flat-patch-sampling
type: topic
---

# Flat Patch Sampling Techniques

Flat patch sampling refers to a class of techniques for selecting, extracting, and manipulating spatially contiguous, fixed-shape regions ("patches") from higher-dimensional signals (e.g., images, 3D volumes) in such a way that the process maintains, reveals, or exploits local spatial structure without hierarchical or deep feature extraction. Across medical image segmentation, neural rendering, and geometric reconstruction, flat patch sampling is used to optimize computational efficiency, achieve geometric disambiguation, or encode scene appearance for novel view synthesis.

## 1. Mathematical Formulations and Sampling Schemes

Several formulations exist under the flat patch sampling paradigm, distinguished by application and by whether the patch selection is stochastic, deterministic, or learned.

### Differentiable Top-k Patch Selection

In 3D medical image segmentation, the No-More-Sliding-Window (NMSW) framework eliminates the computational inefficiency of dense sliding-window (SW) inference by sampling K highly informative patches using a differentiable Top-k mechanism [2501.10814]. The patch candidates are $X_\text{patch} = \{x_i\}_{i=1}^N$, extracted regularly from a high-resolution volume $x_\text{high}$. A global network $f_g(\cdot)$ processes a downsampled input $x_\text{low}$ to emit a categorical score vector $\pi \in [0,1]^N$ with $\sum_{i=1}^N \pi_i = 1$. The Top-k module samples K patch indices via a Gumbel-Softmax/top-k trick:
\[
z_\text{soft} = \mathrm{softmax}_\tau(\log \pi + g), \quad g_i \sim \mathrm{Gumbel}(0,1)
\]
K distinct "soft-hot" vectors $z^{(1)},\ldots,z^{(K)}$ are obtained without replacement, masking previously chosen indices. Final selected patches are extracted by weighted index selection:
\[
x_\text{patch}^{(k^*)} = \langle z^{(k)}, X_\text{patch}\rangle
\]
This is an end-to-end differentiable process for both supervised segmentation and patch sampling [2501.10814].

### Epipolar Flat Patch Sampling in Neural Rendering

For neural rendering, the process is fundamentally geometric. Given a target ray (pixel) in a novel camera view, patches are extracted from reference images centered along the corresponding 3D epipolar line [2207.10662]. For each of K reference views, and M depths $d^m$, local patches $P_k^m$ are sampled around $(u_k^m, v_k^m)$, the projections of $X^m = o_t + d^m v_t$ into each reference frame. Each patch is then flattened (via $\mathrm{vec}(\cdot)$) and linearly projected:
\[
f_p = W_p\, \mathrm{vec}(P) + b_p
\]
No convolutional or recurrent structure is imposed on the patch collection before transformer-based aggregation.

### Sampling for Texture and Geometry Disambiguation

In the geometric reconstruction setting, four or more 2D patches are sampled from observations of a flat, periodic texture imaged under unknown orthographic projections. Each image patch $I_i(u)$ is a warped observation $[{\cal T} \circ T_i^{-1}](u)$, where $T_i$ is a $2\times 2$ positive-determinant warp matrix. The selection of at least four appropriately diverse patches is shown to yield unique recovery (up to in-plane rotation) of both texture and viewing transform, assuming affine independence of the associated $T_i^\top T_i$ matrices [2003.08885].

## 2. Training and Inference Pipelines

### Segmentation with Differentiable Flat Patch Sampling

The NMSW pipeline integrates the Top-k patch mechanism as follows [2501.10814]:

1. Downsample full volume $x_\text{high} \to x_\text{low}$.
2. Global network $f_g$ produces coarse prediction $\hat y_\text{low}$ and patch-selection vector $\pi$.
3. Differentiable Top-k sampling selects K patches $x_\text{patch}^{(k^*)}$.
4. Local backbone processes each patch, yielding localized predictions.
5. An aggregation module fuses upsampled global and patch-wise predictions into a final high-resolution segmentation.

Supervision combines soft-Dice and cross-entropy losses at all stages, with an entropy regularizer on $\pi$ to encourage exploration in patch selection. The process is fully differentiable in all parameters, including the sampler. During inference, hard Top-k selection (maximum $\pi_i$) replaces the stochastic process, yielding a deterministic, budgeted selection of informative regions.

### Patch-based Neural Rendering Pipeline

In [2207.10662], flat patch sampling underpins a transformer-based neural rendering paradigm:

- For a target pixel/ray, extract reference patches $P = \{P_k^m\}$ along the corresponding epipolar lines, at multiple depths.
- Linearly project each patch into a feature vector.
- Concatenate position-encoded depth values, canonicalized ray direction, and camera pose codes.
- Stages of transformers aggregate features: across reference views (at fixed depth), along epipolar lines (per view), and across views again for blending.
- The output color is a two-level attention-weighted blend of pixel intensities from all patches.

This “flat” sampling eschews hierarchical feature learning, relying entirely on local appearance and explicit geometric encoding.

## 3. Geometric Guarantees and Uniqueness Conditions

In the context of reconstructing texture and viewpoint from flat patches, uniqueness depends critically on the diversity and number of sampled warps [2003.08885]:

- A $2\times 2$ warp $T=R_1 F R_2$ (rotations $R_i$, diagonal foreshortening $F$) describes each observation of the texture.
- The set $\{M_i=T_i^\top T_i\}$ must contain at least four affinely independent matrices (i.e., not coplanar on the quadratic “warp cone” defined by $\det(T^\top T - I)=0$) for unique recovery up to global rotation.
- With three or fewer patches, continuous families of non-rotational solutions exist (hyperbolic ambiguities) and textured/helicoidal surfaces may share projections.

A minimal sufficient patch sampling strategy therefore requires at least four generically placed, non-coplanar patches to guarantee uniqueness.

## 4. Computational and Practical Implications

Flat patch sampling, particularly in segmentation and neural rendering, confers substantial computational advantages. In NMSW [2501.10814]:

- Compute (TMACs) is reduced by up to 90% compared to SW (e.g., 87.5 TFLOPs $\rightarrow$ 7.95 TFLOPs for MedNext on 1×480×480×480 input).
- Inference speedup is 4–7× (H100: 19.0s $\rightarrow$ 4.3s; Xeon Gold: 1710s $\rightarrow$ 230s).
- Efficiency gains grow with complexity of the local backbone, since SW costs scale linearly with the number of patches.

In rendering, flat patch sampling enables efficient inference without costly volumetric rendering or CNN feature hierarchies, using localized context and scene geometry [2207.10662].

## 5. Hyperparameters, Ablations, and Sampling Choices

Choices in patch dimensionality, number, and placement impact both efficiency and accuracy.

- In NMSW, increasing $K$ from 5 to 30 improves Dice coefficient from ~0.824 to ~0.853 (WORD/MedNext) with a corresponding increase in FLOPs; very small $K$ leads to under-coverage, extremely large $K$ approaches SW [2501.10814].
- Patch size (e.g., 128³ voxels, 50% overlap) is fixed in both SW and NMSW during training, with little observed gain if varied $\pm25\%$.
- In neural rendering, patch size (16×16), feature projection dimension (256), number of reference views $K$ (10), and number of samples per epipolar line $M$ (15–32) are implementation-tuned [2207.10662].
- For geometric texture/viewpoint reconstruction, sampling at least four, well-separated directions is required for nondegeneracy [2003.08885].

## 6. Advantages, Limitations, and Extensions

### Advantages

- Drastic reductions in computation and memory via selective inference [2501.10814].
- Data-driven or geometry-driven focus on the most informative regions: "active sampling" prioritizes under-segmented or critical areas.
- Flat patch-based neural rendering generalizes novel views without scene-specific learned features or heavy architectural demands [2207.10662].
- Theoretical guarantees for geometric identifiability are attained by careful patch selection [2003.08885].

### Limitations

- Flat patch sampling in segmentation relies on sequential operations (global prediction before local), lowering training throughput compared to fully parallel schemes [2501.10814].
- Top-k module in NMSW samples without replacement; in cases where the object fits entirely within one patch, surplus samples are wasted on background.
- Flat patch sampling assumes planarity in some geometric contexts; for curved surfaces or under perspective projection, uniqueness guarantees may not apply [2003.08885].
- Accurate patch alignment and position encoding are sensitive to noise in geometric and rendering applications.

### Extensions

- Modifying sampling strategies to permit with-replacement draws may yield better coverage in single-object settings.
- The “warp cone” theoretical framework can potentially be extended to weak or full perspective imaging models and to nonstationary texture processes [2003.08885].
- Combining flat patch cues with shading or contour information may resolve ambiguities in geometric reconstruction when fewer than four patches are imposed.

---

*References:*
- NMSW and Top-k sampling for 3D segmentation: [2501.10814]
- Flat patch extraction/encoding in neural rendering: [2207.10662]
- Geometric identifiability from patch warps: [2003.08885]

Source: https://www.emergentmind.com/topics/flat-patch-sampling