A new method for selection of binarization threshold is suggested. It is based on the concept of inter-class border length of a binarized image. Border length is a function of binarization threshold. If the image contains solid objects that are binarized without damaging, and background elements are not revealed, then the border length is almost constant in respect to threshold variation. To the contrary, when binarization leads to object destruction or background penetration, the border length function changes rapidly due to formation of many small clusters of pixels. Basing on this notion, a correct binarization threshold could be chosen. A fast algorithm to find border length function is described, the calculation time being proportional to the pixel count of the grayscale image. Two discrimination parameters derived from this function are suggested. One of them depends on the object line width while the other corresponds to the average curvature of object contour. Basing on a combination of these parameters one can find the optimal binarization threshold provided object line width and/or average curvature is known in advance. Border length method was successfully used for recognition of serial numbers of banknotes in mass-produced equipment. The method recovers object shape and dimensions close to the original, and is almost independent on the background pattern.