According to one embodiment, an image encoding method includes selecting a motion reference block from an encoded pixel block to which an inter prediction is applied. The method includes selecting one or more available blocks from the motion reference block. The method includes selecting a selection block from the available blocks. The method includes generating a predicted image of the encoding target block using motion information of the selection block. The method includes encoding a prediction error between the predicted image and an original image. The method includes encoding selection information specifying the selection block by referring to a code table decided according to a number of the available blocks.