Skip to content

Assignment 6

drebain edited this page Mar 19, 2020 · 1 revision

For this assignment you will be given partially completed skeleton code that contains some of the logic you will need. All areas that you need to add or modify code to to complete the assignment requirements will be marked with a TODO comment and some more specific instructions. It is not necessary to add or modify code outside these sections.

Tasks

(1 mark) Find the Most Common Color in an Image

Complete the populousity algorithm implementation by adding the code to find the most common color given a histogram.

(5 marks) Implement Box Splitting for Median Cut

Implement the split() method for the Box class. This should apply one step of the splitting algorithm described in the Lecture 22 slides to split one box at level N into two boxes at level N + 1.

(1 mark) Find all Boxes with Lowest Level

Add code in find_box_to_split() that builds a list of all the boxes that are "tied" for having the lowest level.

Resources

The description in the slides should be helpful in giving you a visual idea of how the box splitting works.

As before, there are some numpy functions that could make your life a lot easier:

  • np.argsort
  • np.argmax
  • np.sum
  • np.cumsum
  • np.searchsorted

Clone this wiki locally