The invention discloses a
JPEG (Joint Photographic Experts Group) image encoding and decoding method and device and a
computer program product, and relates to the technical field of
image processing. The coding method comprises the following steps: carrying out block
processing on a to-be-coded image; extracting features of each image block; clustering the image blocks into a limited number of categories based on the features; for each category, generating a
quantization matrix of the category according to the
frequency domain coefficient characteristics of the image blocks of the category; and according to the category to which each image block belongs, calling a corresponding
quantization matrix for quantization, and generating a coding code
stream containing the index information and each category of
quantization matrix data. The decoding method comprises the following steps: analyzing a code
stream to obtain index information and quantization matrix data; and determining a corresponding quantization matrix for each image block according to the index information to perform
inverse quantization and image reconstruction. According to the method, the quantization matrixes corresponding to the categories are clustered, so that the
JPEG compression efficiency is remarkably improved, the extra storage and code
stream overhead is effectively controlled, and good compatibility is kept.