Question
Help finish this python assignment!!! def process_header(infile, outfile): for i in range(3): infile.readline() # ** write these lines to the output file def load_image_data(infile): data
Help finish this python assignment!!!
def process_header(infile, outfile): for i in range(3): infile.readline() # ** write these lines to the output file
def load_image_data(infile): data = [] for line in infile.readlines(): line = line.strip() values = line.split(" ") value_int=int(values)# ** convert each value in values to an integer # ** form a row by creating RGB tuples (grouping the values into 3's)
data.append(row)#data.append(row) # commenting this line because row is not defined return data
def process_body(infile, outfile, modification): image_data = load_image_data(infile) # NOTE: check the first and last row in image_data to make sure it looks good #print(image_data[0]) #print(" ") #print(image_data[-1])
def main(): mods = ["negative", "high_contrast"] # ** finish adding string modifications to this list for mod in mods: infile = open("ny.ppm", "r") # ** get the filename from the user outfile = open("ny_negative.ppm", "w") # ** change to use mod and user-spec filename outfile.write(infile.readline()) process_header(infile, outfile) process_body(infile, outfile, mod) outfile.close() infile.close() main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started