Patent ID: 7689048

Claim:
An image encoding apparatus which encodes a pixel value, comprising: an input unit that inputs, in a predetermined scan order, an image to be encoded: a first encoding unit encodes a pixel value of a target pixel using a pixel value of a pixel encoded precedent to the target pixel; a second encoding unit that counts, as a run, a number of pixels having the same value based on an original value, terminates the count and outputs encoded data based on the counted run if the target pixel is a run-ending pixel having a different value from an adjacent pixel; and a switching unit that switches between encoding by said first encoding unit and encoding by said second encoding unit, wherein said switching unit causes, after said second encoding unit outputs encoded data, said first encoding unit to start encoding the target pixel determined as the run-ending pixel, and wherein, when said switching unit switches from said second encoding unit to said first encoding unit, the target pixel is determined as the run-ending pixel, and said first encoding unit encodes the target pixel using a value of a pixel determined as the run-ending pixel other than the target pixel.