4

Deeplab v3 returns a reduced/resized image and its corresponding mask. How can I resize the image as well its corresponding mask to better fit to my specification.

1 Answers1

10

cv2.resize method can be used keeping interpolation method to be cv2.INTER_NEAREST

resized_image = cv2.resize(segmentation_mask, target_dims, interpolation 
=cv2.INTER_NEAREST)

This interpolation method will not lead to change in the RGB values of the labels present in the mask.

If you are saving the masks after resizing, keep the format to be '.png'. Other formats tend to change pixel values by small amount which is not desirable for segmentation masks.

Rachna Pathak
  • 135
  • 1
  • 10