I have this python code for finding coordinates for each pixel in an image. I add 1 to y if a column is finished and 1 to x if a row has finished. The data seems fine during the for loop but when accessing the list after it, it has unknown/wrong items.
import cv2
from colormap import rgb2hex
l = []
image = cv2.imread('image.jpg')
size = image.shape
startcord = [423, 117] #Starting coordinate
rows = size[0] #100
cols = size[1] #100
for i in range(rows):
for j in range(cols):
r, g, b = int(image[i, j, 2]), int(image[i, j, 1]), int(image[i, j, 0])
if r >= 250 and g >= 250 and b >= 250:
pass
else:
hexVal = rgb2hex(r, g, b)
data = (startcord, hexVal, i, j)
print(data) #This gives the right values
l.append(data)
startcord[1] += 1
startcord[1] = 117
startcord[0] += 1
print(l) #When opening, gives unknown/wrong items
I don't know what's wrong, any help is appreciated.
import cv2
from colormap import rgb2hex
l = []
image = cv2.imread('image.jpg')
size = image.shape
startcord = [423, 117] #Starting coordinate
rows = size[0] #100
cols = size[1] #100
for i in range(rows):
for j in range(cols):
r, g, b = int(image[i, j, 2]), int(image[i, j, 1]), int(image[i, j, 0])
if r >= 250 and g >= 250 and b >= 250:
pass
else:
hexVal = rgb2hex(r, g, b)
data = (startcord, hexVal, i, j)
print(data) #This gives the right values
l.append(data)
startcord[1] += 1
startcord[1] = 117
startcord[0] += 1
print(l) #When opening, gives unknown/wrong items
I don't know what's wrong, any help is appreciated.