import sys
import os.path
from algorithms import *

def main(argv):
    filename = argv[0] if len(argv) > 0 else "input.png"
    algorithm = argv[1] if len(argv) > 1 else "lbp"
    num_processes = int(argv[2]) if len(argv) > 2 else 1

    algorithms = {
        "lbp": LBP.LBP,
        "multi-lbp": Multiprocessing_LBP.Multiprocessing_LBP,
        "multi-split-lbp": Multiprocessing_Split_LBP.Multiprocessing_Split_LBP
    }
    if algorithm not in algorithms:
        print("Invalid algorithm '{}'".format(algorithm))
        return

    algorithm_class = algorithms[algorithm]

    if os.path.isfile(filename):
        run = algorithm_class(filename, num_processes)
        run.execute()
    else:
        print("File '{}' does not exist.".format(filename))

if __name__ == "__main__":
    main(sys.argv[1:])

import sys
import os.path
import argparse
from algorithms import *

def main(argv):
    # Argument parsing
    parser = argparse.ArgumentParser(description='Run the local binary patterns algorithm using either a single process or multiple processes.')
    parser.add_argument('--input', dest='input', type=str, default='input.png', help='file name of the input image')
    parser.add_argument('--algorithm', dest='algorithm', type=str, default='lbp', help='algorithm to use: "lbp", "multi-lbp" or "multi-split-lbp"')
    parser.add_argument('--processes', dest='processes', type=int, default=1, help='number of processes to use (only relevant for multiprocessing)')
    arguments = parser.parse_args()

    algorithms = {
        "lbp": LBP.LBP,
        "multi-lbp": Multiprocessing_LBP.Multiprocessing_LBP,
        "multi-split-lbp": Multiprocessing_Split_LBP.Multiprocessing_Split_LBP
    }
    if arguments.algorithm not in algorithms:
        print("Invalid algorithm '{}'".format(arguments.algorithm))
        return

    algorithm_class = algorithms[arguments.algorithm]

    if os.path.isfile(arguments.input):
        run = algorithm_class(arguments.input, arguments.processes)
        run.execute()
    else:
        print("File '{}' does not exist.".format(arguments.input))

if __name__ == "__main__":
    main(sys.argv[1:])

Convert main.py to improved argument parsing logic