1

Suppose I have an image with mask, valid pixels are masked as 1 and others 0, how to perform bilinear interpolation to fill all the invalid pixels?

for example, image: 1, 0, 0, 4

mask: 1, 0, 0, 1

interpolation result should be: 1, 2, 3, 4

The valid pixels are not regularly arranged, a more complicated sample, image:

4, 0, 6, 0,

0, 8, 5, 0

5, 3, 0, 0

mask:

1, 0, 1, 0,

0, 1, 1, 0

1, 1, 0, 0


interpolate with scipy.interpolate.interp2d and the result has many holes and noise uv of vertex uv after interpolation

Lamp
  • 302
  • 1
  • 10
  • For me it is unclear how you want ro interpolate when there are several 1 masked pixels surrounding a 0 contour. Could delauny triangulation and phong-shading be an option? – Micka Dec 23 '21 at 08:09
  • @Micka thanks, found some interesting solutions at: https://stackoverflow.com/questions/35807321/scipy-interpolation-with-masked-data – Lamp Dec 23 '21 at 08:24
  • don't do that. explain instead what your input is and *why*. -- a similar question recently tried to do an affine/perspective transformation, and they assigned pixels in the destination, which left a lot of holes... and that was a completely wrong approach. -- if you **really have to**, inpainting can be one approach. – Christoph Rackwitz Dec 23 '21 at 12:14
  • @ChristophRackwitz I try to calculate UV coordinates of 3D human, but only know UV of vertex. I'll project the vertex to an image, and interpolate all other pixels. It may cause some problem near seams but basically should work. – Lamp Dec 23 '21 at 15:13
  • 1
    so... projecting a texture (the image) onto a model. an entirely 3d graphics problem. has nothing to do with pytorch or opencv. you'll need to learn about graphics programming (opengl/vulkan/d3d) – Christoph Rackwitz Dec 23 '21 at 15:21

0 Answers0