Hi,<br><br>I have an image with masked-out (invalid) pixels. The masked-out pixels aren't just on the border, there are many masked pixels all over the image area.<br><br>I want to compute the gradient image of this image.<br>
<br>The standard way to compute the gradient is to convolve with a Gaussian kernel and then with a derivative kernel. This causes the invalid pixels' values to "leak out" to nearby pixels. So if there were say 20% invalid pixels in the original image, the gradient image will have maybe 80% invalid pixels, because their values are functions of one or more nearby invalid pixels.<br>
<br>I don't know of a standard solution to this problem, but I've thought of two ideas.<br><br>One idea is to program a smart blurring operator that is "mask aware". It will take a weighted average each neighborhood like a Gaussian kernel, except that masked pixels won't be included in the average. Blurring with this kernel won't make the masks leak out.<br>
<br>The other idea is to do inpainting of the masked out pixels, i.e. replace the invalid pixels with valid values that are based on a smart interpolation of their neighborhood. Then I can apply a standard gradient filter on the resulting image.<br>
<br>I'd appreciate any ideas or implementation tips.<br><br>- Aviv<br>