Masks for image segmentation are created by assigning a label to each pixel in an image, indicating which object or region it belongs to. In practice, this is done by annotating images with binary masks or using tools like LabelMe or VGG Image Annotator. These masks are then used to train segmentation models like U-Net or Mask R-CNN.