An image decoding method performed by a decoding apparatus, the method comprising: receiving a bitstream; obtaining a two-dimensional array of transform coefficients based on the received bitstream; deriving a plurality of first transform coefficients from a top-left 4x4 region of the two-dimensional array of transform coefficients; deriving a plurality of second transform coefficients based on an inverse secondary transform of the plurality of first transform coefficients; deriving a two-dimensional array of values based on the plurality of second transform coefficients, wherein the plurality of second transform coefficients are mapped to a top-left 8x8 region of the two-dimensional array of values, excluding a bottom-right 4x4 region within the top-left 8x8 region based on a width of a target block being equal to or greater than 8 and a height of the target block being equal to or greater than 8, and wherein the plurality of second transform coefficients are mapped to a top-left 4x4 region of the two-dimensional array of values based on a size of the target block being 4xN or Nx4 (N≥4); deriving an array of residual samples based on an inverse primary transform of the two-dimensional array of values; and generating a reconstructed picture based on the array of residual samples, wherein the deriving the plurality of second transform coefficients comprises: performing a matrix operation between a transform kernel matrix and the plurality of first transform coefficients, in which the plurality of first transform coefficients are arranged according to a forward diagonal scanning order of the top-left 4x4 region of the two-dimensional array of transform coefficients, wherein the matrix operation between the transform kernel matrix and the plurality of first transform coefficients of the top-left 4x4 region is (48 x 16 matrix) * (16 x 1 transform coefficient vector), and wherein the plurality of second transform coefficients are two-dimensionally arranged in the two-dimensional array of values according to a row-first direction or a column-first direction corresponding to an intra prediction mode applied. receiving a bitstream; obtaining a two-dimensional array of transform coefficients based on the received bitstream; deriving a plurality of first transform coefficients from a top-left 4x4 region of the two-dimensional array of transform coefficients; deriving a plurality of second transform coefficients based on an inverse secondary transform of the plurality of first transform coefficients; deriving a two-dimensional array of values based on the plurality of second transform coefficients, wherein the plurality of second transform coefficients are mapped to a top-left 8x8 region of the two-dimensional array of values, excluding a bottom-right 4x4 region within the top-left 8x8 region based on a width of a target block being equal to or greater than 8 and a height of the target block being equal to or greater than 8, and wherein the plurality of second transform coefficients are mapped to a top-left 4x4 region of the two-dimensional array of values based on a size of the target block being 4xN or Nx4 (N≥4); deriving an array of residual samples based on an inverse primary transform of the two-dimensional array of values; and generating a reconstructed picture based on the array of residual samples, wherein the deriving the plurality of second transform coefficients comprises: performing a matrix operation between a transform kernel matrix and the plurality of first transform coefficients, in which the plurality of first transform coefficients are arranged according to a forward diagonal scanning order of the top-left 4x4 region of the two-dimensional array of transform coefficients, wherein the matrix operation between the transform kernel matrix and the plurality of first transform coefficients of the top-left 4x4 region is (48 x 16 matrix) * (16 x 1 transform coefficient vector), and wherein the plurality of second transform coefficients are two-dimensionally arranged in the two-dimensional array of values according to a row-first direction or a column-first direction corresponding to an intra prediction mode applied. performing a matrix operation between a transform kernel matrix and the plurality of first transform coefficients, in which the plurality of first transform coefficients are arranged according to a forward diagonal scanning order of the top-left 4x4 region of the two-dimensional array of transform coefficients, wherein the matrix operation between the transform kernel matrix and the plurality of first transform coefficients of the top-left 4x4 region is (48 x 16 matrix) * (16 x 1 transform coefficient vector), and wherein the plurality of second transform coefficients are two-dimensionally arranged in the two-dimensional array of values according to a row-first direction or a column-first direction corresponding to an intra prediction mode applied.