compute optimal filter size