Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How does np.zeros() create a black background?

I am creating a very simple line drawing program. The problem is that i am still in the learning stage and I jsut stumbled across a problem.

import numpy as np import cv2

Create a black image

img = np.zeros((512,512,3), np.uint8)

Draw a diagonal blue line with thickness of 5 px

img = cv2.line(img,(0,0),(511,511),(255,0,0),5)

how does np.zeros((512,512,3), np.uint8) create a black back ground? What if i want to create a red or a green background?

I hope this answers my problem! Thanks!! :)

How does np.zeros() create a black background?

I am creating a very simple line drawing program. The problem is that i am still in the learning stage and I jsut stumbled across a problem.

import numpy as np import cv2

Create a black image

img = np.zeros((512,512,3), np.uint8)

Draw a diagonal blue line with thickness of 5 px

img = cv2.line(img,(0,0),(511,511),(255,0,0),5)

how does np.zeros((512,512,3), np.uint8) create a black back ground? What if i want to create a red or a green background?

I hope this answers my problem! Thanks!! :)

How does np.zeros() create a black background?

I am creating a very simple line drawing program. The problem is that i am still in the learning stage and I jsut stumbled across a problem.

import numpy as np import cv2

img = np.zeros((512,512,3), np.uint8)

img = cv2.line(img,(0,0),(511,511),(255,0,0),5)

how does np.zeros((512,512,3), np.uint8) create a black back ground? What if i want to create a red or a green background? And also, what does these 2 parameters mean?

I hope this answers my problem! Thanks!! :)