First commit is required if your training data contains empty samples with no present objects
Second commit should be a more general version that allows for non-identical step sizes in x and y. Also, I think labelBox.height and lB.width were mixed up.