Factor out dithering matrix threshold calculation