COS 126 – Atomic Theory of Matter

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Chapter 7. Binary Search Trees
The Singleton Pattern II Recursive Linked Structures.
1 Various Methods of Populating Arrays Randomly generated integers.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
1 Video Processing Lecture on the image part (8+9) Automatic Perception Volker Krüger Aalborg Media Lab Aalborg University Copenhagen
Observe Brownian motion of particles.
CSCI 103 – Atomic Theory of Matter. Goal of the Assignment Calculate Avogadro’s number Using Einstein’s equations Using fluorescent imaging Input data.
COS 126 – Atomic Theory of Matter. Goal of the Assignment Calculate Avogadro’s number Using Einstein’s equations Using fluorescent imaging Input data.
MACHINE LEARNING 9. Nonparametric Methods. Introduction Lecture Notes for E Alpaydın 2004 Introduction to Machine Learning © The MIT Press (V1.1) 2 
CS 206 Introduction to Computer Science II 01 / 21 / 2009 Instructor: Michael Eckmann.
Stacks.
Sets and Maps Chapter 9. Chapter 9: Sets and Maps2 Chapter Objectives To understand the Java Map and Set interfaces and how to use them To learn about.
COS 126 – Atomic Theory of Matter. Atomic Theory Overview Brownian Motion Random collision of molecules Displacement over time fits a Gaussian distribution.
CS 206 Introduction to Computer Science II 10 / 14 / 2009 Instructor: Michael Eckmann.
COS 126 – Atomic Theory of Matter. Announcements Project – due Friday (1/12) midnight TA Office Hours this week (check website) Lab Help (Mon-Fri 7pm-9pm)
Aalborg Media Lab 21-Jun-15 Software Design Lecture 2 “ Data and Expressions”
Introduction to Computer Science Exam Information Unit 20.
Classes, Objects, Arrays, Collections and Autoboxing Dr. Andrew Wallace PhD BEng(hons) EurIng
ICS 145B -- L. Bic1 Project: Main Memory Management Textbook: pages ICS 145B L. Bic.
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
The Mole and Avogadro’s Number
CS 206 Introduction to Computer Science II 09 / 10 / 2009 Instructor: Michael Eckmann.
Pointers OVERVIEW.
THE MOLE CONTENTS What is a mole and why do we use it? Calculating the number of moles of a single substance Reacting mass calculations.
Sets, Maps and Hash Tables. RHS – SOC 2 Sets We have learned that different data struc- tures have different advantages – and drawbacks Choosing the proper.
Connected Components Fun with graphs, searching, and queues.
Georgia Institute of Technology Movies Barb Ericson Georgia Institute of Technology April 2006.
COS 126 – Atomic Theory of Matter. Goal of the Assignment Calculate Avogadro’s number Using Einstein’s equations Using fluorescent imaging Input data.
Chapter 11 The Mole
COS 126 – Atomic Theory of Matter. Goal of the Assignment Calculate Avogadro’s number Using Einstein’s equations Using fluorescent imaging Input data.
Section 6.1 Atoms and Moles 1.To understand the concept of average mass 2.To learn how counting can be done by weighing 3.To understand atomic mass and.
Where’s the title? You gotta search for it!. PotW Solution String s = new Scanner(System.in).next(); int[] prev = new int[s.length() * 2 + 2]; Arrays.fill(prev,
Vocabulary of Mole Theory. ___ is the amount produced from a reaction in reality. actual yield.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Session 7 More Implications of Inheritance & Chapter 5: Ball World Example.
Section 6.1 Atoms and Moles 1.Students will be able to describe the concept of average mass. 2.Students will be able to demonstrate how counting can be.
Chapter 11.  1. Describe how a mole is used in chemistry.  2. Relate a mole to common counting units.  3. Convert the number of moles to the number.
2.4 A Case Study: Percolation Introduction to Programming in Java: An Interdisciplinary Approach · Robert Sedgewick and Kevin Wayne · Copyright © 2008.
WHAT IS A MOLE? SI unit for Amount of Substance A mole is a unit like “dozen” or “pair” or “gross”. It doesn’t represent a measured number, but a counted.
Building Java Programs Generics, hashing reading: 18.1.
Mathematical Derivation of Probability
Sets and Maps Chapter 9.
Chapter 7 User-Defined Methods.
Real-Time Soft Shadows with Adaptive Light Source Sampling
Chapter 5 Ordered List.
Chapter 7 Part 1 Edited by JJ Shepherd
COSC160: Data Structures Linked Lists
ENEE150 Discussion 13 Section 0101 Adam Wang.
Java Software Structures: John Lewis & Joseph Chase
Efficiency add remove find unsorted array O(1) O(n) sorted array
Chemistry – Apr 4, 2018 P3 Challenge –
What/how do we care about a program?
Optimizing Malloc and Free
Chapter 5 Ordered List.
Lesson Objectives Aims
COS 126 – Atomic Theory of Matter
COS 126 – Atomic Theory of Matter
CSE 143 Lecture 2 Collections and ArrayIntList
Sets, Maps and Hash Tables
10.1 What is a Mole? A mole of any substance contains Avogadro’s number of representative particles, or 6.02  1023 representative particles. The term.
Observe Brownian motion of particles.
COS 126 – Atomic Theory of Matter
COS 126 – Atomic Theory of Matter
Sets and Maps Chapter 9.
CSE 143 Lecture 2 ArrayIntList, binary search
State Machines 8-May-19.
State Machines 16-May-19.
Error Correction Coding
2.4 A Case Study: Percolation
Presentation transcript:

COS 126 – Atomic Theory of Matter

Goal of the Assignment Calculate Avogadro’s number Input data Output Using Einstein’s equations Using fluorescent imaging Input data Sequence of images Each image is a rectangle of pixels Each pixel is either light or dark Output Estimate of Avogadro’s number

Assignment: Four Programs Blob data type Maximal set of connected light pixels BlobFinder Find all blobs in a JPEG image List all the big blobs (aka beads) BeadTracker Track beads from one image to the next Avogadro Data analysis to estimate Avogadro’s number from the motion of beads

Atomic Theory Overview Brownian Motion Random collision of molecules Displacement over time fits a Gaussian distribution

Atomic Theory Overview Avogadro’s Number Number of atoms needed to equal substance’s atomic mass in grams NA atoms of Carbon-12 = 12 grams Can calculate from Brownian Motion Variance of Gaussian distribution is a function of resistance in water, number of molecules

Blob.java API for representing particles (blobs) in water public Blob() public void add(int i, int j) public int mass() // number of pixels public double distanceTo(Blob b) // from center (average) public String toString() Only need three values to efficiently store Do not store the positions of every pixel in the blob Center of mass, and # of pixels

Blob Challenges Format numbers in a nice way Thoroughly test String.format("%2d (%8.4f, %8.4f)", mass, cx, cy); (Use same format in System.out.printf()) E.g., "%6.3f" -> _2.354 E.g., "%10.4e" -> 1.2535e-23 Thoroughly test Create a simple main()

BlobFinder.java Locate all blobs in a given image API And identify large blobs (called beads) API public BlobFinder(Picture picture, double threshold) Calculate luminance (see Luminance.java, 3.1) Count pixels with a luminance >= threshold Find blobs with DFS (see Percolation.java, 2.4) The hard part, next slide… public Blob[] getBeads(int minSize) Returns all beads with at least minSize pixels Array must be of size equal to number of beads

BlobFinder - Depth First Search Use boolean[][] array to mark visited Traverse image pixel by pixel Dark pixel Mark as visited, continue Light pixel Create new blob, call DFS DFS algorithm Base case: simply return if Pixel out-of-bounds Pixel has been visited Pixel is dark (and mark as visited) Add pixel to current blob, mark as visited Recursively visit up, down, left, and right neighbors

BlobFinder - Depth First Search Use boolean[][] array to mark visited Traverse image pixel by pixel Dark pixel Mark as visited, continue Light pixel Create new blob, call DFS DFS algorithm Base case: simply return if Pixel out-of-bounds Pixel has been visited Pixel is dark (and mark as visited) Add pixel to current blob, mark as visited Recursively visit up, down, left, and right neighbors

BlobFinder - Depth First Search Use boolean[][] array to mark visited Traverse image pixel by pixel Dark pixel Mark as visited, continue Light pixel Create new blob, call DFS DFS algorithm Base case: simply return if Pixel out-of-bounds Pixel has been visited Pixel is dark (and mark as visited) Add pixel to current blob, mark as visited Recursively visit up, down, left, and right neighbors

BlobFinder - Depth First Search Use boolean[][] array to mark visited Traverse image pixel by pixel Dark pixel Mark as visited, continue Light pixel Create new blob, call DFS DFS algorithm Base case: simply return if Pixel out-of-bounds Pixel has been visited Pixel is dark (and mark as visited) Add pixel to current blob, mark as visited Recursively visit up, down, left, and right neighbors

BlobFinder - Depth First Search Use boolean[][] array to mark visited Traverse image pixel by pixel Dark pixel Mark as visited, continue Light pixel Create new blob, call DFS DFS algorithm Base case: simply return if Pixel out-of-bounds Pixel has been visited Pixel is dark (and mark as visited) Add pixel to current blob, mark as visited Recursively visit up, down, left, and right neighbors

BlobFinder - Depth First Search Use boolean[][] array to mark visited Traverse image pixel by pixel Dark pixel Mark as visited, continue Light pixel Create new blob, call DFS DFS algorithm Base case: simply return if Pixel out-of-bounds Pixel has been visited Pixel is dark (and mark as visited) Add pixel to current blob, mark as visited Recursively visit up, down, left, and right neighbors

BlobFinder Challenges Data structure for the collection of blobs Store them any way you like But, be aware of memory use

BlobFinder Challenges Data structure for the collection of blobs Store them any way you like But, be aware of memory use Array of blobs? But, how big should the array be? Linked list of blobs? Memory efficient, but harder to implement Anything else? Submit your (extra) object classes

BeadTracker.java Track beads between successive images Single main function Take in a series of images Output distance traversed by all beads for each time-step For each bead found at time t+1, find closest bead at time t and calculate distance Not the other way around! Don’t include if distance > 25 pixels (new bead)

BeadTracker Challenges Reading multiple input files java BeadTracker run_1/*.jpg Expands files in alphabetical order End up as args[0], args[1], … Avoiding running out of memory How? Recompiling Recompile if Blob or BlobFinder change

BeadTracker Challenges Reading multiple input files java BeadTracker run_1/*.jpg Expands files in alphabetical order End up as args[0], args[1], … Avoiding running out of memory Do not open all picture files at same time Only two need to be open at a time Recompiling Recompile if Blob or BlobFinder change

Avogadro.java Analyze Brownian motion of all calculated displacements Lots of crazy formulas, all given, pretty straightforward Be careful about units in the math, convert pixels to meters, etc. Can test without the other parts working We provide sample input files Can work on it while waiting for help

Conclusion: Final Tips Avoiding subtle bugs in BlobFinder Don’t pass Blobs between private methods … it makes bugs hard to track down Common errors in BlobFinder NullPointerException StackOverflowError (e.g., if no base case) No output (need to add prints) Look at checklist Q&A

Conclusion: Final Tips Testing with a main() BlobFinder, BeadTracker, and Avogadro Must have a main() that can handle I/O described in Testing section of checklist Timing analysis Look at feedback from earlier assignments BeadTracker is time sink, so analyze that How can you run 100 frames?