implementation of library function to generate cr mask (to be tested)