An image decoding method performed by a decoding apparatus, the method comprising: obtaining intra prediction type information and residual related information for a current block from a bitstream; deriving transform coefficients for the current block based on information on quantized transform coefficients included in the residual related information; and generating residual samples of the current block based on the transform coefficients, wherein the intra prediction type information includes a matrix based intra prediction, MIP, flag representing whether MIP is applied to the current block, wherein a value of the MIP flag equal to 0 represents that the MIP is not applied to the current block, and the value of the MIP flag equal to 1 represents that the MIP is applied to the current block, wherein in response to the MIP being applied to the current block as the value of the MIP flag is equal to 1, prediction samples of the current block are derived by reducing, through averaging, neighboring reference samples of the current block, performing a matrix-multiplication on the reduced neighboring reference samples, and adding an offset (b k) to values on which the matrix-multiplication is performed, wherein a size of the matrix (A k) used for the matrix-multiplication is determined in response to a size of the current block, wherein the size of the matrix (A k) is 16×8 in response to the size of the current block being 8×8, wherein whether the residual related information includes low frequency non-separable transform, LFNST, index information or not for the current block is based on the MIP flag, wherein the residual samples are generated from the transform coefficients based on the LFNST index information, wherein the residual related information includes the LFNST index information based on the value of the MIP flag being not equal to 1, and wherein the LFNST index information is configured in a coding unit syntax based on the MIP flag. obtaining intra prediction type information and residual related information for a current block from a bitstream; deriving transform coefficients for the current block based on information on quantized transform coefficients included in the residual related information; and generating residual samples of the current block based on the transform coefficients, wherein the intra prediction type information includes a matrix based intra prediction, MIP, flag representing whether MIP is applied to the current block, wherein a value of the MIP flag equal to 0 represents that the MIP is not applied to the current block, and the value of the MIP flag equal to 1 represents that the MIP is applied to the current block, wherein in response to the MIP being applied to the current block as the value of the MIP flag is equal to 1, prediction samples of the current block are derived by reducing, through averaging, neighboring reference samples of the current block, performing a matrix-multiplication on the reduced neighboring reference samples, and adding an offset (b k) to values on which the matrix-multiplication is performed, wherein a size of the matrix (A k) used for the matrix-multiplication is determined in response to a size of the current block, wherein the size of the matrix (A k) is 16×8 in response to the size of the current block being 8×8, wherein whether the residual related information includes low frequency non-separable transform, LFNST, index information or not for the current block is based on the MIP flag, wherein the residual samples are generated from the transform coefficients based on the LFNST index information, wherein the residual related information includes the LFNST index information based on the value of the MIP flag being not equal to 1, and wherein the LFNST index information is configured in a coding unit syntax based on the MIP flag.