Monday, 8 November 2021

Why does my code not add the lists it is given even though it is told to do so?

I have been trying to add the RGB values of each pixel in an image but for some reason the code gives me an warning and refuses to add the values or to store them in the a list.

error:

RuntimeWarning: Main.py:46: RuntimeWarning: overflow encountered in ubyte_scalars
  rgb2 = red2[counter]+green2[counter]+blue2[counter]

code:

import cv2

lib = ['Map1.png']

Read = list(cv2.imread(lib[0]))

while True:

    for i in range(len(Read)):  # y coords
        for j in range(len(Read[i])):  # x coords
            blue = list(Read[i][j])[0]
            green = list(Read[i][j])[0]
            red = list(Read[i][j])[0]
            rgb = blue + green + red
            lib3 = []
            lib3.append(rgb)
            print(lib3)

Map1:

enter image description here



from Why does my code not add the lists it is given even though it is told to do so?

No comments:

Post a Comment