1. A method for encoding an image including a plurality of pixels, comprising: classifying each pixel of the image as one of a plurality of pixel classifications; defining the image as a plurality of blocks of pixels; for each block, classifying that block as one of a plurality of block classifications based on the pixel classifications of pixels in that block; for each block, performing a discrete cosine transform upon that block to produce a transformed matrix corresponding to that block and including transform coefficients for that block; for each transformed matrix and corresponding block, quantizing the transform coefficients of that transformed matrix using a selected quantization table according to the block classification of that block to produce a quantized matrix corresponding to that block; for each quantized matrix and corresponding block, performing an inverse discrete cosine transform on that quantized matrix to produce a filtered image portion, the filtered image portions together comprising a filtered image; and performing a JPEG compression on the filtered image, wherein a specific pixel is classified by analyzing the intensity values of a plurality of pixels in an N by N window centered around that specific pixel, the analysis including: determining a first maximum value of a first plurality of values that includes the sums of the intensity values of each row of the N by N window, determining a first minimum value of that first plurality of values, and calculating a first difference between the first maximum value and the first minimum value; determining a second maximum value of a second plurality of values that includes the sums of the intensity values of each column of the N by N window, determining a second minimum value of that second plurality of values, and calculating a second difference between the second maximum value and the second minimum value; and classifying a pixel as halftone if the first difference and the second difference are less than or equal to a first predefined threshold T1, and wherein said method is performed by a processor.