1. A method for block-based encoding of an image having a plurality of blocks of pixels, using a video encoder, the method comprising: processing the image using an initial quantization step size to obtain predictions and residuals for each of the blocks of pixels; transforming the respective residuals to obtain initial transform domain coefficients for each of the blocks of pixels; calculating a variance for each coefficient position across all the initial transform domain coefficients; determining a quantization distortion for each coefficient position in a block, based on a predetermined pixel domain distortion, by selecting the quantization distortions based on the variances for the coefficient positions, subject to linear constraints on the quantization distortions, wherein the linear constraints are based upon the predetermined pixel domain distortion; selecting a quantization step size for each coefficient position in the block, based on the quantization distortion for that coefficient position; applying the block-based transform to each of the blocks of pixels to generate a set of transform domain coefficients for each block of pixels; for each set of transform domain coefficients, quantizing each of the transform domain coefficients using the selected quantization step size for that transform domain coefficient's coefficient position to produce a quantized coefficient; and encoding the quantized coefficients to generate a bitstream of encoded image data.