About Mask Registration

I want to complete a mask registration and add a mask to the dicom sequence(3D) to speed up the registration. I found an example, but it is 2d and does not explain how to get the mask(I do not know how to create the mask). Can someone help me?