lundi 28 octobre 2019

python if statement printing more than it should

i am working on building a model and trying to get the rgb value of the pixels in a specific image before i move into labeling the data the if statement below printing right but the value should be incremented only by 1 not keep looping. can you help to know the reason?

for image in train_data[10:11]:
  img = Image.open(image)
  rgb_im = img.convert('RGB')
  for x in range(rgb_im.size[0]):
    for y in range(rgb_im.size[1]):
      r1, g1, b1 = rgb_im.getpixel((x, y))
      if (r1,g1,b1) == color and x == 445 and y == 60:
        countPositive += 1
        print(countPositive)
      else:
        countNegative += 1
        print(countNegative)

print screen to the output from google colab

Aucun commentaire:

Enregistrer un commentaire