+ 18

Python code help

Hello . Help . py I want to write a code for get colors average for a image I want to write it in python This is the code I wrote But the result is not what I want This code should calculate the average of all image pixels and display the average as a color I is something like ""the colos of motion"" So help me, what should i do ? ""' import cv2 import numpy as np import matplotlib.pyplot as plt image=cv2.imread("MIT_Dome_night1_Edit.jpg") # reading pic #for see the main pic image=cv2.cvtColor(image, cv2.COLOR_RGB2BGR) plt.imshow(image) plt.show() # print (image) if you want see all matrix sumim = sum(image) print ("sum with sum function",sumim) # print sum pic damantion = image.shape print("damantion",damantion) # (height 1610, width clear2644, channels 3) cv2.imwrite("color_sum.jpg", sumim) plt.imshow(sumim) plt.show() a=cv2.sumElems(image) print ("sum whith cv2",a) # for show sum in pic backgn_black img=np.zeros(damantion) img[20:50]=sumim cv2.imwrite("myimg.jpg", img) plt.imshow(img) plt.show() """

27th Oct 2020, 10:22 PM
Donya Khoobani
Donya Khoobani - avatar
1 Answer
+ 7
https://www.sololearn.com/post/710146/?ref=app The result should look like this photo We input the image (imread) Then we calculate the average of the image colors As a result, and we should thet at the a pic (here it is just a Green pic )
27th Oct 2020, 10:30 PM
Donya Khoobani
Donya Khoobani - avatar