The invention relates to an encoding device, a decoding device, and a recording medium. This encoding device is provided with: a circuit that derives a gradient and an absolute value, which are the absolute value of the sum of a gradient value in a first range and a gradient value in a second range, and derives, as a first parameter, the sum of a plurality of gradients and absolute values derived for each of a plurality of relative pixel positions; a pixel difference value, which is the difference between the pixel values in the first range and the pixel values in the second range, is derived, and the sign of the pixel difference value is inverted or maintained by the sign of the gradient sum, which is the sum of the gradient values in the first range and the gradient values in the second range, to derive each of a plurality of relative pixel positions. And derives, as a second parameter, the sum of the difference values of the plurality of pixels in which the sign symbols are inverted or maintained, and generates a predicted image using the first parameter and the second parameter.