Statistical mechanics of image restoration and error-correcting codes.