To reduce the processing required to embed a code into image data and
decode the code. The present invention includes a block dividing section
101 that divides original image data 10 into a plurality of blocks
(M.times.N); an averaging section 103 that extracts each average density
(characteristic amount) in a plurality of blocks; and an encoding section
106 that embeds a code C (a plurality of bits) into a plurality of blocks
by relating one code (one bit out of the code C) to each pair of blocks
mutually located in near position in the plurality of blocks based on a
magnitude relation of the average density.