Presentation is loading. Please wait.

Presentation is loading. Please wait.

Centroids part 2 Getting rid of outliers and sorting.

Similar presentations


Presentation on theme: "Centroids part 2 Getting rid of outliers and sorting."— Presentation transcript:

1 Centroids part 2 Getting rid of outliers and sorting

2 Last time… Bounding Box Centroids Algorithms Big O notation

3 Are centroids foolproof? What if we have ridiculously large outliers? Consider the following thresholded points in a 400 by 300 image: (0,0),(0,1),(0,2),(1,0),(1,1),(1,2),(2,0),(2,1), (2,2),(200,200) Which point doesn’t belong?

4 Outliers Pieces of data that lie outside the usual distribution of data are considered outliers. What is considered “outside?” Somewhat subjective question. Statisticians often use a 1.5*IQR test – Anything 1.5 * the inter-quartile range below the first or above the third counts.

5 Outliers in thresholding The outliers in a thresholded image can be thought of as “noise” There are several different ways to get rid of noise, but we will start with the most basic We will modify the centroid algorithm to be more robust

6 Robust centroid The correction is simple: Instead of calculating the centroid with all of the data points, we will disregard the bottom 5% and the top 5%. How do we go about doing this? The answer lies in sorting

7 Sorting Sorting algorithms are a basic part of computer science We will focus on comparison sorts: Sorting algorithms that work solely upon comparing two items together and determining whether one is greater to, equal to, or less than the other.

8 Some examples! Dumb sort Bubble sort Selection sort Merge sort Quick sort

9 Running time considerations Sorting algorithms are often used to demonstrate the uses of big O notation and running time considerations We will go into a few examples!

10 Dumb sort! The idea: Create a random permutation of the list of numbers, and check to see if it’s sorted. Repeat until it is!

11 Bubble sort The idea: Go through the list of numbers, and compare each element to the one above it: If it’s greater, then swap the two. Repeat until sorted!

12 Selection sort The idea: Go through the list and find the smallest element, then swap it with the first element. Continue with the second smallest, third smallest, etc.

13 Merge sort The idea: Recursively divide the list into 2 roughly equally sized smaller lists When you get to the bottom, merge the 2 lists together recursively until you get a sorted list

14 A pretty mergesort picture

15 Quick sort The idea: Pick a pivot element: Divide the list into elements that are smaller than the pivot, equal to the pivot, and greater than the pivot Recursively sort the smaller and greater lists

16 A prettier quicksort picture

17 Back to the robust centroid Once we have a sorted list of x values and y values, we can do one of two things: 1.) Take off the lowest and highest points 2.) Take off the lowest and highest x and y values What’s the difference?


Download ppt "Centroids part 2 Getting rid of outliers and sorting."

Similar presentations


Ads by Google