I want to achieve the following and am wondering if there is a nice, efficient way in PyTorch:
Given an RGB Image as a 3D-Tensor with gaps at certain pixel locations, I want to fill these gaps with randomly drawn pixels from the distribution of existing pixels inside that image.
Does anyone have any idea? Thank you very much in advance!
Here is a small example, inside
a = torch.Tensor(
[[[3,4,0],[0,2,3],[1,3,0]],
[[1,3,0],[0,2,1],[1,2,0]],
[[3,3,0],[0,1,3],[1,2,0]]])
replace all triples [0,0,0]
along the first axis (axis = 0
) with randomly drawn triplets from the other triplets in a
along the first axis.
So a possible solution would be
a_filled = torch.tensor(
[[[3,4,2],[1,2,3],[1,3,2]],
[[1,3,2],[1,2,1],[1,2,2]],
[[3,3,1],[1,1,3],[1,2,1]]])
another one would be
a_filled = torch.tensor(
[[[3,4,4],[3,2,3],[1,3,1]],
[[1,3,3],[2,2,1],[1,2,1]],
[[3,3,3],[2,1,3],[1,2,1]]])