I'm trying to mark regions of an image array (224x224) to be ignored based on the value of a segmentation network's class mask (16x16). Previous processing means that unwanted regions will be labelled as -1. I want to be able to set the value of all regions of the image where the class mask reports -1 to some nonsense value (say, 999), but maintain the shape of the array (224x224). A concise example of what I mean is below, using a 4x4 image and 2x2 mask.
# prefilter
image = 1 2 3 4
5 6 7 8
9 1 2 3
4 5 6 7
mask = -1 4
-1 5
# postfilter
image_filtered = 999 999 3 4
999 999 7 8
999 999 2 3
999 999 6 7
Is there an efficient way to do this modification?