Avoid generating the mask outside the bounded area