Creating Image Using Python Code.
Step 1: Install cv2 Module.
command : pip install opencv-python.
Step 2: Import cv2 and Numpy
Step 3: Create an Blank image using Numpy.
command : numpy.zeros((height,width,3))
numpy.zeros : It is having 3 colors in the form of
i.e , (B , G , R) = ( 0 , 0, 0 ) so ‘3’:BGR color
numpy.uint8 : Unsigned integer (0 to 255)
Step 4 : Start to draw the image as per your wish using some functions.
I have just created a nested for loop for assigning colors dividing the image
for i in range(h) : the range of height which we have given as 512
for j in range(w) : the range of width which we have given as 512
we have already intialized A in previous steps
Therefore, we start assigning colors to the given height and width.
step 4 : To see the output:
Syntax: cv2.imshow(window_name, image) #display image
cv2.waitkey(time in ms) # wait for a specific time in milliseconds
cv2.destroyAllWindows() # destroy the window after displaying the image
Hope you find it Intresting ..!!