Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Scientific Programming – 2023/2024

Coursework 2 – Part 2: Algorithms and optimisation

In the previous coursework (coursework 1), dental XRay scans were loaded as numpy ndarrays, which could then be processed directly. In the first part of this coursework, an Image class was used to encapsulate any input image and manipulate it.

During this part (CW2-P2), we will expand the functionality associated with our Image class. Using inheritance, we are creating a BinaryImage class based on the Image class. It encapsulates binary images (in the form of a Boolean Numpy ndarray) and implements the computation of a connected component image (we used this function in coursework 1).

The provided connected_comp member method calls a recursive function. As a result, it is limited to small images as very large image objects would require too many recursive calls and would thus yield a RecursionError.

Part 1: First, modify the provided test_image.py file to ensure the BinaryImage.connected_comp member method is thoroughly tested.

Marking scheme: 20 points

Part 2: Second, you are expected to write your own implementation to calculate a connected component image without using recursion. Your implementation should be implemented in the BinaryImage.connected_comp_no_recursion method. Your implementation should rely on Numpy and no other module should be imported.

Marking scheme: 40 points

Part 3: Third, your task is to implement an accelerated version of your BinaryImage. connected_comp_no_recursion implementation in the BinaryImage.

connected_comp_fast method. Use the approach of your choice or a combination of approaches to improve your code efficiency: algorithmic, concurrency, compiled language,

Marking scheme: 30 points

Part 4: Finally decorate the three connected component functions (BinaryImage. connected_comp,  BinaryImage.connected_comp_no_recursion,

BinaryImage.connected_comp_fast) to display each call computation time.

Marking scheme: 10 points

While developing your methods, do not hesitate to create a Jupyter Notebook to visualise your results. You are expected to submit your coursework as a compressed folder containing, the altered image.py and image_test.py files. See the coursework submission section on Keats for the submission date.