Upon rendering I store an image containing pass_index
property as a 16 bit, single channel. However upon loading this image using bpy.data.images.load
it returns a 4 channel image.
My issue is that I need to access the pass_index
property from the image once again, but I am unable to find those values in the 4 channel image. So how do I get the pass_index
values again?
I use the following code
maskPath = Path()
maskImg = bpy.data.images.load(str(maskPath))
width, height = maskImg.size[0], maskImg.size[1]
print ('\n width: {}, height: {}'.format(width, height))
imgArray = np.array(maskImg.pixels[:], dtype=np.float32).reshape(height, width, 4)
print (np.unique(imgArray))
Note: I am able to load this image from a different python terminal using non-Blender image loading techniques and am able to access the pass_index
values.