Automatic threshold selection for profiles of attribute filters based on granulometric characteristic functions