Digital download
$25.00
- Availability
- In stock
- Checkout
- One item
Need a hand?
Message us on WhatsApp for payment or download support.
| The topic of this coursework will be theDevelopment of a software tooltosplit an image from top to bottombased onlowestchangeofintensities |
Finally, it should be noted that this is an individual project, and your code will be automatically checked for plagiarism and collusion. In the event, plagiarism is detected, you will be reported for miss-conduct. You can find more information about the relevant processes on this page.
You are expected to submit a single zipped folder containing only three python files named main.py, squareimage.py and test_squareimage.py. This should be submitted via the dedicated Keats submission section on the 7MRI0020 module page, where the deadline is specified. Your submission should be anonymised, so do not include any identifiable information in the filename of the notebook nor in your code.
The aim of this coursework is to create a software tool to detect the path which links the top of an image (any pixel from the top row) to the bottom (any pixel from the bottom row) while minimising the overall absolute intensity differential on the path.
Starting from a 2D grid, we aim to establish a path that links any pixel from the top row to any pixel from the bottom row while satisfying these conditions: - (Condition 1) A given pixel on a row (red) can only be connected to the pixel under it on the following row or the two voxels on either side of the central one (blue), as illustrated beside. - (Condition 2) The sum of absolute differential value between all pixels on the path should be minimal. For example, the total value associated with the path highlighted in blue (2-4-2-1-5) on the right-hand side figure would be computed as: |2-4| + |4-2| + |2-1| + |1-5| Note that the path shown is not the optimal solution to the problem.Task 1 [40 marks]: The provided code implements a naive approach that evaluates all possible solutions (brute force) for a square image and returns a best solution for the aforementioned task.
The provided `find_minimal_path_brute_force` method lacks modularity and is hard to validate as it implements all required functionalities to extract the best path. Rewrite the components of this method into multiple methods instead. You should call the `find_minimal_path_alternative` method instead of `find_minimal_path_brute_force`.
Ensure all methods you add, including `find_minimal_path_alternative`, are thoroughly tested. Create a file `test_squareimage.py` to implement your unit tests using the `unittest` module. For example, the following function:| deflarge_function():
a =np.random.randint(10)
b=a*10c=b**2returnc |
| defroutineA(): returnnp.random.randint(10) defroutineB(v): return v*10 defroutineC(v):return v**2 def split_function():a=routineA()b =routineB(a)c =routineC(b)returnc |