Averaging is often used to increase the quality of an image degraded by noise or artifacts. A method is developed in which several degrees of freedom are introduced in the averaging process, this freedom making possible the choice of different weighting factors for different portions of the Fourier space. If a weighting factor is associated with each line of a magnetic resonance acquisition, we show that we obtain some freedom to eliminate motion artifacts. The process minimizes a quantity called the gradient energy over a region of interest in the image plane. A processed image is obtained from a mosaic of such regions of interest scanned over the whole image plane. The method is shown to yield greater motion artifact suppression in magnetic resonance images than that achieved with regular averaging. The main strength of the method is probably its ability to diminish the intensity of unstructured artifacts which are usually poorly managed by other postprocessing methods of artifacts suppression.