"""
Usage: python challenge_problem.py <image_filename>

Program for segementing nuclei in the provided image.

Note: We provide the show_image function, the load_image function and the main function for your convenience. However, 
feel free to add, edit or remove any part of this file.
"""


from PIL import Image
import matplotlib.pyplot as plt
import sys
import numpy as np


def show_image(im_array):
    """
    Displays an image represented as a numpy array.

    im_array: numpy array representing an image.
    """
    plt.imshow(im_array)
    plt.show()

def load_image(filename):
    """
    Loads a provided image and returns it as a numpy 
    array.

    filename: String representing image filename. 
    """
    im = Image.open(filename)
    im_array = np.array(im)
    return im_array

def main():
    args = sys.argv
    if len(args) < 2:
        print("Please specify a filename.")
    else:
        filename = args[1]
        im_array = load_image(filename)
        show_image(im_array)



if __name__ == "__main__":
    main()