404pio
404pio

Reputation: 1032

Opencv binary mask into white and blue mask

Let's say I have a mask (100, 100) of 1's and 0's:

mask = np.random.randint(0, 2, size=(100, 100))

How to convert this mask to get white-and-blue image in RGB:

Upvotes: 0

Views: 167

Answers (1)

404pio
404pio

Reputation: 1032

Easy as piece of cake. You need auxiliary array to do it:

img = np.zeros((100, 100, 3))
img[mask==0,:] = [1, 1, 1] 
img[mask==1,:] = [0, 0, 1] 

Upvotes: 1

Related Questions