On-line Handwritten Japanese Characters Recognition Using a MRF Model with Parameter Optimization by CRF