I have a list of mask images with the shape of(3100,3100,3),
I want to create a new image with 5 channels ( 3100,3100,5)
form each image to represent the different colours in each mask. I searched for the specific colours in each image to get the pixel coordinates of each colour,
after that I want to insert these pixels into the new 5 channel image:
# Define the colours
green= [0,255,0]
blue=[ 0, 0, 255]
yel=[255, 255, 0]
red=[ 255, 0, 0]
white=[255, 255, 255]
# create the new image with 5 channels
new_img=np.zeros( ( np.array(mask).shape[0], np.array(mask).shape[1], 5 ) )
# find each colour coordinate
new_img[0,0,1]=np.where(np.all(mask==green,axis=2))
new_img[0,0,2]=np.where(np.all(mask==blue,axis=2))
new_img[0,0,3]=np.where(np.all(mask==yel,axis=2))
new_img[0,0,4]=np.where(np.all(mask==red,axis=2))
new_img[0,0,5]=np.where(np.all(mask==white,axis=2))
it shows this error, how can I create this 5 channel image?
> TypeError Traceback (most recent call last)
TypeError: float() argument must be a string or a number, not 'tuple'
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
<ipython-input-197-5b9c268857b2> in <module>
19 new_img=np.zeros( ( np.array(mask).shape[0], np.array(mask).shape[1], 5 ) )
20
---> 21 new_img[0,0,1]=np.where(np.all(mask==benign,axis=2))
22 new_img[0,0,2]=np.where(np.all(mask==blue,axis=2))
23 new_img[0,0,3]=np.where(np.all(mask==yel,axis=2))
ValueError: setting an array element with a sequence.