speedup by (1) moving scanX/Y values outside the slice loop. (2) summing mask3M only for more then one segment per slice.
speedup by (1) moving scanX/Y values outside the slice loop. (2) summing mask3M only for more then one segment per slice.

cerr/CERR,cerr/CERR,aditiiyer/CERR,aditiiyer/CERR,cerr/CERR,aditiiyer/CERR,cerr/CERR,aditiiyer/CERR,aditiiyer/CERR,cerr/CERR,aditiiyer/CERR,aditiiyer/CERR,aditiiyer/CERR,cerr/CERR,cerr/CERR,cerr/CERR,cerr/CERR