Faster mask calculation using ROI