a part of PR269 (parallelization of several functions) by Alexander Mordvintsev

optical flow part is excluded for now, since it degrades performance for some reason (to be investigated later)