An encoder which encodes a current block to be encoded in an image, the encoder comprising: circuitry (106, 108, 110, ex455); and memory (118, 122, ex467), wherein the circuitry (106, 108, 110, ex455) is configured, using the memory (118, 122, ex467): to perform a primary transform on residuals of the current block to obtain primary coefficients; to determine whether a secondary transform is to be applied to the current block; (i) to calculate quantized primary coefficients by performing a first quantization on the primary coefficients when the secondary transform is not to be applied, (ii) to perform a secondary transform on the primary coefficients to obtain secondary coefficients, and to calculate quantized secondary coefficients by performing a second quantization on the secondary coefficients, when the secondary transform is to be applied; and to generate an encoded bitstream by encoding either the quantized primary coefficients or the quantized secondary coefficients, wherein the first quantization is a weighted quantization using a first quantization matrix, the second quantization is a weighted quantization using a second quantization matrix different from the first quantization matrix, and characterized in that the circuitry (106, 108, 110, ex455) is further configured: to derive a third quantization matrix from the first quantization matrix by applying a monotonously decreasing function to each component value of the first quantization matrix; to derive a fourth quantization matrix by applying the secondary transform to the third quantization matrix; and to derive, as the second quantization matrix, a fifth quantization matrix from the fourth quantization matrix by applying a monotonously decreasing function to each component value of the fourth quantization matrix. circuitry (106, 108, 110, ex455); and memory (118, 122, ex467), wherein the circuitry (106, 108, 110, ex455) is configured, using the memory (118, 122, ex467): to perform a primary transform on residuals of the current block to obtain primary coefficients; to determine whether a secondary transform is to be applied to the current block; (i) to calculate quantized primary coefficients by performing a first quantization on the primary coefficients when the secondary transform is not to be applied, (ii) to perform a secondary transform on the primary coefficients to obtain secondary coefficients, and to calculate quantized secondary coefficients by performing a second quantization on the secondary coefficients, when the secondary transform is to be applied; and to generate an encoded bitstream by encoding either the quantized primary coefficients or the quantized secondary coefficients, wherein the first quantization is a weighted quantization using a first quantization matrix, the second quantization is a weighted quantization using a second quantization matrix different from the first quantization matrix, and characterized in that the circuitry (106, 108, 110, ex455) is further configured: to derive a third quantization matrix from the first quantization matrix by applying a monotonously decreasing function to each component value of the first quantization matrix; to derive a fourth quantization matrix by applying the secondary transform to the third quantization matrix; and to derive, as the second quantization matrix, a fifth quantization matrix from the fourth quantization matrix by applying a monotonously decreasing function to each component value of the fourth quantization matrix. to perform a primary transform on residuals of the current block to obtain primary coefficients; to determine whether a secondary transform is to be applied to the current block; (i) to calculate quantized primary coefficients by performing a first quantization on the primary coefficients when the secondary transform is not to be applied, (ii) to perform a secondary transform on the primary coefficients to obtain secondary coefficients, and to calculate quantized secondary coefficients by performing a second quantization on the secondary coefficients, when the secondary transform is to be applied; and to generate an encoded bitstream by encoding either the quantized primary coefficients or the quantized secondary coefficients, wherein the first quantization is a weighted quantization using a first quantization matrix, the second quantization is a weighted quantization using a second quantization matrix different from the first quantization matrix, and characterized in that the circuitry (106, 108, 110, ex455) is further configured: to derive a third quantization matrix from the first quantization matrix by applying a monotonously decreasing function to each component value of the first quantization matrix; to derive a fourth quantization matrix by applying the secondary transform to the third quantization matrix; and to derive, as the second quantization matrix, a fifth quantization matrix from the fourth quantization matrix by applying a monotonously decreasing function to each component value of the fourth quantization matrix. to derive a third quantization matrix from the first quantization matrix by applying a monotonously decreasing function to each component value of the first quantization matrix; to derive a fourth quantization matrix by applying the secondary transform to the third quantization matrix; and to derive, as the second quantization matrix, a fifth quantization matrix from the fourth quantization matrix by applying a monotonously decreasing function to each component value of the fourth quantization matrix.