store multiple images efficiently in Python data structure
PIL and Pillow are only marginally useful for this type of work. 
The basic algorithm used for "finding and counting" objects like you are trying to do goes something like this: 1. Conversion to grayscale 2. Thresholding (either automatically via Otsu method, or similar, or by manually setting the threshold values) 3. Contour detection 4. Masking and object counting based on your contours. 
You can just use a Mat (of integers, Mat1i) would be Data structure fits in this scenario.
I have several images (their number might increase over time) and their corresponding annotated images - let's call them image masks.
I want to convert the original images to Grayscale and the annotated masks to Binary images (B&W) and then save the gray scale values in a Pandas DataFrame/CSV file based on the B&W pixel coordinates. 
So that means a lot of switching back and forth the original image and the binary images.
I don't want to read every time the images from file because it might be very time consuming.
Any suggestion which data structure should be used for storing several types of images in Python?