0

I am making a database from a randomly modified picture and i want to save each modification. This is my code but i have an error with the integer i inside the for loop.

How can i then save the pictures and use i for their names ?

import numpy as np
import cv2
import random
import os

image = cv2.imread('positive/30.jpg')

def modif_img(img):
    #HERE IS WHERE I MODIFY MY PICTURE
    return img

nbr = 3
for i in nbr:
    newImage = modif_img(image)
    #cv2.imshow("New image", newImage)
    path = './positive/30'
    cv2.imwrite(os.path.join(path, 'a' + str(i) + '.bmp'), newImage)
1
  • for i in range(nbr) Commented Nov 5, 2020 at 19:35

1 Answer 1

1

Replace this line as integers are in range function in python to iterate

for i in range(nbr):
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you it worked but for only 15 images. Do you know maybe why can't i do like a hundred images ? even nbr=20 it didn't work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.