1. An image decoding method comprising: decoding first transform coefficients for a target image to be decoded and information indicating an intra-prediction mode for the target image; judging whether a first condition or a second condition is satisfied in the intra-prediction mode; setting both a vertical inverse transform matrix and a horizontal inverse transform matrix as a first transform matrix, when the first condition is satisfied; inversely transforming the first transform coefficients along a vertical direction using the first transform matrix and a horizontal direction using the first transform matrix to obtain a first prediction error; generating a first decoded image of the target image based on the first prediction error; setting both the vertical inverse transform matrix and the horizontal inverse transform matrix as a second transform matrix different from the first transform matrix, when the second condition is satisfied; inversely transforming the first transform coefficients along the vertical direction using the second transform matrix and the horizontal direction using the second transform matrix to obtain a second prediction error; and generating a second decoded image of the target image based on the second prediction error, wherein a first coefficient density of second transform coefficients obtained by performing a first single dimension transform using the second transform matrix on a third prediction error of an intra-prediction image predicted by referencing reference pixels on a line is bigger than a second coefficient density of third transform coefficients obtained by performing a second single dimension transform using the first transform matrix on the third prediction error, and a direction of the first single dimension transform and a direction of the second single dimension transform are perpendicular to the line.