Dear @Nicholas Tiveron ,
you should simply create a "new image" using the data structure that was mentioned in the class (list of lists) and save it as
The new images should encode the information as mentioned in the text.
The program has to save the image before returning the #rects.
Given the errors that you posted (No such file or directory etc), I suggest you debug what happens in the testing phase or if the image is saved correctly. Can you clearly see the images saved in your filesystem? Can you open it with a simple editor? I suggest you place a breakpoint at the line of code where you get the error and proceed from there.
I hope this helps,