Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resize segmentation mask obtained from Deeplab v3?

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.

like image 283
Ahmad Bilal Khalid Avatar asked Oct 25 '25 22:10

Ahmad Bilal Khalid


1 Answers

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.

like image 116
Rachna Pathak Avatar answered Oct 28 '25 02:10

Rachna Pathak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!