Dark theme

Answers


So, here's one answer: restructured.py; imagelib.py; .

If you look at restructured.py you'll see it has been stripped down to just a brief set of function calls with clear names so that this clearly and simply tells the story of the code; this is good practice: it is much clearer what is going on.

We've enabled this by splitting each chunk of code up into separate methods and making them generic. This improves re-usability of both the overall class and the functions: we could, for example, use it without display, or just to display, or add new processing routines. By having code in callable functions we've made it much more flexible as we can call them as we like, or not, to do different jobs. Not also that there's no global variables in this class, meaning we could use it in a fucntional manner, e.g.:
processor.write_image("out.txt",
    processor.smooth_image(
        processor.read_image("in.txt")
    , neighbourhood_diameter)
)

In terms of other refactoring, we haven't done a lot; mainly just adding with uses.