Do w and h calculations before thresholding