COS 126 – Atomic Theory of Matter. Goal of the Assignment Calculate Avogadro’s number Using Einstein’s equations Using fluorescent imaging Input data.

Slides:



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

Chapter 7. Binary Search Trees
CS203 Lecture 15.
The Singleton Pattern II Recursive Linked Structures.
Contest format 5 hours, around 8-12 problems One computer running (likely)Linux, plus printer 3 people on one machine No cell phones, calculators, USB.
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
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.
CS 267: Automated Verification Lecture 10: Nested Depth First Search, Counter- Example Generation Revisited, Bit-State Hashing, On-The-Fly Model Checking.
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)
Creating Shareable Models By: Eric Hutton CSDMS - Community Surface Dynamics Modeling System (pronounced ˈ s ɪ stəms) Image by Flickr user Let There Be.
Introduction to Computer Science Exam Information Unit 20.
Chapter 12 Trees. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Define trees as data structures Define the terms.
Introduction - The Need for Data Structures Data structures organize data –This gives more efficient programs. More powerful computers encourage more complex.
Classes, Objects, Arrays, Collections and Autoboxing Dr. Andrew Wallace PhD BEng(hons) EurIng
Using Moles to Count Atoms
ImageJ EE4H, M.Sc Computer Vision Dr. Mike Spann
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.
Chapter 7: Chemical Formulas and Chemical Compounds
CS 206 Introduction to Computer Science II 09 / 10 / 2009 Instructor: Michael Eckmann.
This week in CS 5 HW 9 (2 problems) M/T sections W/Th sections due Sunday, 11/4 at midnight due Monday, 11/5 at midnight Recitation for HW9 -- Friday 11/2.
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.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
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.
02 Variables1November Variables CE : Fundamental Programming Techniques.
Graphs – Part II CS 367 – Introduction to Data Structures.
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.
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,
1 Directed Graphs Chapter 8. 2 Objectives You will be able to: Say what a directed graph is. Describe two ways to represent a directed graph: Adjacency.
Hash Tables and Hash Maps. DCS – SWC 2 Hash Tables A Set and a Map are both abstract data types – we need a concrete implemen- tation in order to use.
Vocabulary of Mole Theory. ___ is the amount produced from a reaction in reality. actual yield.
Sets and Maps Chapter 9. Chapter Objectives  To understand the Java Map and Set interfaces and how to use them  To learn about hash coding and its use.
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.
1 A Case Study: Percolation Percolation. Pour liquid on top of some porous material. Will liquid reach the bottom? Applications. [ chemistry, materials.
2.4 A Case Study: Percolation Introduction to Programming in Java: An Interdisciplinary Approach · Robert Sedgewick and Kevin Wayne · Copyright © 2008.
Arrays Chap. 9 Storing Collections of Values 1. Introductory Example Problem: Teachers need to be able to compute a variety of grading statistics for.
Building Java Programs Chapter 12: Recursive public/private pairs Chapter 13: Searching reading: 13.3.
Chemical Reactions Balancing Equations. n In order to show that mass is conserved during a reaction, a chemical equation must be balanced n You do this.
Building Java Programs Generics, hashing reading: 18.1.
Chapter 7 User-Defined Methods.
Chapter 5 Ordered List.
COS 126 – Atomic Theory of Matter
Efficiency add remove find unsorted array O(1) O(n) sorted array
Chapter 5 Ordered List.
COS 126 – Atomic Theory of Matter
COS 126 – Atomic Theory of Matter
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
State Machines 8-May-19.
State Machines 16-May-19.
Presentation transcript:

COS 126 – Atomic Theory of Matter

Goal of the Assignment Calculate Avogadro’s number 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 N A 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 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" -> e-23 Thoroughly test Create a simple main()

BlobFinder.java Locate all blobs in a given image 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

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

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?