Linear prediction schemes, such as that of the Joint Photographic Experts Group (JPEG), are simple and normally produces a residual sequence with lower zero-order entropy. Occasionally the entropy of the prediction error becomes greater than that of the original image. Such situations frequently occur when the image data have discrete gray levels located within certain intervals. To alleviate this problem, various authors have suggested different preprocessing methods. However, the techniques reported require two passes. We extend the definition of Lehmer-type inversions (Lehmer 1960 and 1964) from permutations to multiset permutations and present a one-pass algorithm based on inversions of a multiset permutation. We obtain comparable results when we apply JPEG and even better results when we apply some other linear prediction schemes on a preprocessed image, which is treated as multiset permutation.