Finished the initial part of reading input parameters and setting up the output image