Convert a 3-dimensional RGB mage into a 1-dimensional binary image : I can convert the RGB image into binary but its dimensions are still too large `(1280x720x3)`. Since each pixel of the binary image only has a value of 0 or 1, I want to reduce its dimension to `(1280x720x1)` so I won't have to deal with memory issues (since I'm working with thousands of images).

    import cv2
    import glob
    
    def convert_to_binary(source_path, destination_path):
        i = 0
        
        for filename in glob.iglob("{}*.png".format(source_path)):
            im_gray = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)
            (thresh, im_bw) = cv2.threshold(im_gray, 128, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
            cv2.imwrite("{}{}.png".format(destination_path, str(i)), im_bw)
            i += 1

How could I modify the above code to change the dimensions of saved images from `(1280x720x3)` to `(1280x720x1)`?