Created
August 21, 2019 13:13
-
-
Save luxedo/250ab64d7e598b5e98de549e2f1400d9 to your computer and use it in GitHub Desktop.
Mean pixel of images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Start with a bang!""" | |
import argparse | |
from os import path | |
import cv2 | |
import numpy as np | |
def main(args): | |
px_acc = [] | |
for img_path in args.images: | |
img = cv2.imread(img_path) | |
px_acc.append(img.mean(1).mean(0)) | |
print(list(np.mean(px_acc, axis=0))[::-1]) | |
def check_file(string): | |
if not path.isfile(string): | |
raise argparse.ArgumentTypeError("File {} not found".format(string)) | |
return string | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser(description="calculates the mean pixel of images") | |
parser.add_argument("images", nargs="*", type=check_file) | |
args = parser.parse_args() | |
main(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment