Download presentation
Presentation is loading. Please wait.
Published byRachel Horton Modified over 6 years ago
1
So where is it anyway? Bounding box, median, centroids, and an introduction to algorithm analysis
2
Last time… Storing an image on a computer Working with an image
Introduction to image segmentation: thresholding
3
Thresholding Lets us separate the pixels we want from the pixels we don’t want Works with color and brightness
4
So we have a thresholded image…
Now what? We need to get useful information out of the new image! Most importantly, we need to know where the thresholded object is
5
Bounding box Simple idea – draw a box around all the relevant pixels
Smallest possible box, of course!
6
Finding the bounding box
So, how would we go about finding the bounding box? We must search for the topmost, bottommost, leftmost, and rightmost pixels. How can we do this the fastest?
7
Now what? We want to track a precise point where the object is, not a box Why? The most obvious way is to calculate the center of the box Demonstrate with bounding box program
8
On second thought… Why isn’t this always a good idea?
Noise will make the measurements inaccurate!
9
Can we do better? A better idea is to find the centroid of the pixels
Centroid = Mean, only in 2 dimensions! With the centroid, we can better figure out where the densest area is
10
Calculating the centroid
To find the average x-value, we average the x-values of all the data points. Similarly, to find the average y-value, we average the y-values of all the data points. How do we do this?
11
For example… We have the points (3,4); (2,3); (6,1); (5,4)
The x-values are: 3, 2, 6, 5 The average x-value is ( )/4 = 4 The y-values are: 4, 3, 1, 4 The average y-value is ( )/4 = 3 The centroid is (4,3) Explain how in reality, calculating a centroid would require infinitely many data points, and must thus be done in another way.
12
Algorithms The method to find the centroid is called an “algorithm”
An algorithm is a procedure to solve a problem Algorithms do not depend on the language you use! Give many, many examples!
13
How does it fit? Using computer science, you want to solve a PROBLEM.
You design an ALGORITHM to solve the problem. Finally, you write an IMPLEMENTATION to tell the computer how to use the algorithm to solve the problem.
14
Analyzing an algorithm
An algorithm can be considered a “function.” It take in input, and spits out output. In most cases in computer science, the input can vary in size.
15
Centroids revisited How big is the input size in the centroid-finding algorithm? It depends on the number of pixels that have been thresholded in! For analysis purposes, the size is considered “n.” “n” is simply a variable representing the size.
16
Big O notation Given the input size as n, how many times does the algorithm use the n elements to produce its output? This is called “big O analysis” It lets us gauge how fast an algorithm will run as the amount of input increases
17
Best case vs. worst case Sometimes, an algorithm might not necessarily NEED to process all n elements in its input. Often, it can end after it has found what it’s looking for. Computer scientists, however, prefer to look at the WORST CASE scenario.
18
Examples of analysis An algorithm f(n) can be, for example, O(1), O(n), O(n2), O(log(n)), etc… These are pronounced “Order of one,” “Order of n,” etc…
19
Technical definition An algorithm f(n) is O(g(n)) if for all real numbers x > x0 and M > 0, f(x) <= M*g(x). This means: An algorithm that’s O(n) is ALSO O(n2).
20
How does this help? Big O analysis lets us determine how fast an algorithm will run. As n gets huge, this makes a tremendous difference!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.