merge_patches¶
- dnois.utils.merge_patches(patches: Tensor | list[list[Tensor]], overlap: int | tuple[int, int] = 0, merge_method: Literal['avg', 'crop', 'slope', 'sum'] = 'avg') Tensor ¶
Merge a set of patches into an image.
- Parameters:
patches (Tensor | list[list[Tensor]]) – Either a tensor of shape PR x PC x … x PH x PW or a 2d list composed of tensors of shape … x PH x PW, wherein PR, PC are numbers of patches in vertical and horizontal direction and PH, PW are height and width of each patch, respectively.
overlap (int | tuple[int, int]) – Overlapping width in vertical and horizontal direction.
merge_method (Literal['avg', 'crop', 'slope']) –
The method used to determine the values of overlapping pixels.
avg
In each overlapping position, pixels of involved patches are averaged.
crop
Both of two overlapping patches fill half the overlapping region.
slope
In each overlapping position, pixels of involved patches are averaged where the component closer to its patches has larger weights.
sum
Pixels of involved patches are summed up in all overlapping positions.
Default:
avg
.
- Returns:
A resulted image of shape … x H x W.
- Return type:
Tensor