# Is there a way to get rid of this square artifact coming from lens distortion?

I've got a noisy render that I'd like to composite with slight lens distortion (Fit=True, Distort=0.03, Dispersion=0.001):

I'm noticing a repeating pattern of square artifacts in the output of the lens distortion node. Here is zoomed in on the lens-distorted image:

Is there a way to improve the quality of this lens distortion?

This is not a bug. It is simply how the the image manipulation algorithm works. This must be fairly common since Corel seems to use a similar algorithm in Paint Shop Pro:

It's worth noting that the square pattern only appears close to the center... outside the center it becomes more like a concentric circular pattern radiating out.

The reason for these artifacts is that you are distorting an image made up of square pixels. Ideally, this is what would happen to the pixel array:

However, you obviously cannot distort the pixels themselves and still have a proper 2D array that can be read by typical image software. So you must do some sort of combination of deleting and averaging of pixels. Because that can't be done on a pixel level (there are no fractions of pixels), the image must be subdivided into sections in order to deal with each subset. In the center, it makes sense to do this in square sections (since the distortion is minimal), but on the edges it should be concentric sections (since the distortion is circular in nature).

A uniformly noisy image (with large, flat, mono-chromatic planes) is pretty much the worst case scenario for this algorithm because of the contrast between individual pixels on sections that would otherwise have little variation. You probably wouldn't even notice the artifacts on a smooth image unless you were really pixel-peeping. Here's the same distortion applied to an image rendered at 500 samples:

In short, this is to be expected. The only way I know to reduce the effect is to apply noise reduction before distortion in your Composite node chain, or start with a less noisy image. Essentially, the lower the contrast between individual pixels, the less visible the artifacts will be.

• I agree with @bertmoog that increasing the samples will help. As a workaround, try to render the image at a higher resolution (or a larger image size) and then resize it back to the intended image size to make the artifacts less noticeable. – user1853 Oct 5 '17 at 20:53

See https://photo.stackexchange.com/a/29646 for an example, the last sample image with visual block structure. If this is the case, saving as PNG or TGA or nearly anything other than JPG will fix the squares, since it's the JPG format itself that's adding them.