We develop a statistical-mechanical formulation for image restoration and e
rror-correcting codes. These problems are shown to be equivalent to the Isi
ng spin glass with ferromagnetic bias under random external fields. We prov
e that the quality of restoration/decoding is maximized at a specific set o
f parameter values determined by the source and channel properties. For ima
ge restoration in a mean-field system a line of optimal performance is show
n to exist in the parameter space. These results are illustrated by solving
exactly the infinite-range model. The solutions enable us to determine how
precisely one should estimate unknown parameters. Monte Carlo simulations
are carried out to see how far the conclusions from the infinite-range mode
l are applicable to the more realistic two-dimensional case in image restor
ation. [S1063-651X(99)02807-X].