Fully Automatic Photometric Determination of the Total Base Number (TBN)