Image impainting

Hi all, I’m currently implementing some CV operation on image impainting,
For example I have an image (pytorch) with size (C, H, W) (C may greater than 3) and I want to keep non-zeros pixel and fill the 0-value pixel with background, how can I do this. I do not need to do backpropagation so you can use CV or numpy operations.

image

Thank you in advance

An example of the 64x32x32 image (I calculated mean of the first dimension then plot it)

image

You could create a mask based on the zero pixels, index the tensor/array with it, and assign the new values to it.

thanks @ptrblck, but we still have to fill them with appropriate values, right? I need a proper way to calculate the value of these pixel

Wouldn’t the mask be the same for the background image?

I cannot calculate the value of the background image pixel @ptrblck, I think that we need some heuristic method

What do you want the background to be?

I have tried filling the zero-valued pixel with the top left pixel of the original image for example but it look not natural at all, my point is can we do some heuristic methods like apply gaussian CNN kernels or stuff like that with the aim of creating natural images

anybody can gimme a help on this, please

I think you’ll have to be a bit more specific about what you’re looking for. Creating natural images is a whole field and it can get really challenging (google GANs). You asked about some simple heuristic method, which sounds like a good idea, but without knowing what your domain is or more details it’s very difficult to blindly suggest a reasonable heuristics. Typically good heuristics require intuition about the domain.