0

I am looking to save a set of processed images into a folder within my directory. There have been similar questions (e.g., Save images in loop with different names), however they either use user defined functions or rely on the images being part of a video that they decompose frame-by-frame and then save.

Using another question, I was looking to accomplish something similar (OpenCV - Saving images to a particular folder of choice), but within a loop structure

import cv2
import os

path = 'D:\Results'

for i in range(len(images))
     cv2.imwrite(os.path.join(path, 'waka.tif'), )
     cv2.waitKey(0)

But am unsure of what to put in place of the waka title the previous questioner gave the image.

Cameron F.
  • 193
  • 2
  • 11

2 Answers2

2

you can put 'waka_{}.tif'.format(i) this will save one image every time it goes through the loop and you will then have waka_1.tif, waka_2.tif, etc.

api55
  • 11,070
  • 4
  • 41
  • 57
Alefunxo
  • 58
  • 6
1

you can try this:

import cv2
import os

path = 'D:\Results'

for i in range(len(images))
     cv2.imwrite(os.path.join(path, 'waka_'+str(i)+'.tif'), )
     cv2.waitKey(0)
mee
  • 688
  • 8
  • 18