CSCI 103 – 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 7. Binary Search Trees
Advertisements

Linked Lists.
CS203 Lecture 15.
CS252: Systems Programming Ninghui Li Program Interview Questions.
E.G.M. PetrakisImage Segmentation1 Segmentation is the process of partitioning an image into regions –region: group of connected pixels with similar properties.
Chapter 6: Stacks STACK APPLICATIONS STACK IMPLEMENTATIONS CS
This Time Pointers (declaration and operations) Passing Pointers to Functions Const Pointers Bubble Sort Using Pass-by-Reference Pointer Arithmetic Arrays.
Observe Brownian motion of particles.
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 
COS 126 – Atomic Theory of Matter. Atomic Theory Overview Brownian Motion Random collision of molecules Displacement over time fits a Gaussian distribution.
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)
Main Index Contents 11 Main Index Contents Container Types Container Types Sequence Containers Sequence Containers Associative Containers Associative Containers.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 2 “ Data and Expressions”
Chapter 12 Trees. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Define trees as data structures Define the terms.
Graphs & Graph Algorithms Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Ray Tracing.
C++ Functions. 2 Agenda What is a function? What is a function? Types of C++ functions: Types of C++ functions: Standard functions Standard functions.
Trees, Tre-Like Structures, Binary Search Trees, Balanced Trees, Tree Traversals, DFS and BFS Svetlin Nakov Telerik Software Academy academy.telerik.com.
Implementing Stacks Ellen Walker CPSC 201 Data Structures Hiram College.
Data Structures Using C++ 2E
1 CSC 222: Computer Programming II Spring 2004 Pointers and linked lists  human chain analogy  linked lists: adding/deleting/traversing nodes  Node.
COP3530 Data Structures600 Stack Stack is one the most useful ADTs. Like list, it is a collection of data items. Supports “LIFO” (Last In First Out) discipline.
ICS 145B -- L. Bic1 Project: Main Memory Management Textbook: pages ICS 145B L. Bic.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
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.
Stacks. A stack is a data structure that holds a sequence of elements and stores and retrieves items in a last-in first- out manner (LIFO). This means.
DATA STRUCTURES LAB 1 TA: Nouf Al-harbi
Pointers OVERVIEW.
Objective At the conclusion of this chapter you will be able to:
Connected Components Fun with graphs, searching, and queues.
Digital Camera and Computer Vision Laboratory Department of Computer Science and Information Engineering National Taiwan University, Taipei, Taiwan, R.O.C.
Graphs – Part II CS 367 – Introduction to Data Structures.
COS 126 – Atomic Theory of Matter. Goal of the Assignment Calculate Avogadro’s number Using Einstein’s equations Using fluorescent imaging Input data.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Stacks.
Chapter 9: A Second Look at Classes and Objects
COS 126 – Atomic Theory of Matter. Goal of the Assignment Calculate Avogadro’s number Using Einstein’s equations Using fluorescent imaging Input data.
Copyright © 0 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Java From Control Structures through Data Structures by Tony.
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.
Object-Oriented Programming in C++ Lecture 4 Constants References Operator overloading.
Chapter 5 Linked List by Before you learn Linked List 3 rd level of Data Structures Intermediate Level of Understanding for C++ Please.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
Chapter 1 C++ Basics Review (Section 1.4). Classes Defines the organization of a data user-defined type. Members can be  Data  Functions/Methods Information.
Java & C++ Comparisons How important are classes and objects?? What mechanisms exist for input and output?? Are references and pointers the same thing??
1 Linked Lists Assignment What about assignment? –Suppose you have linked lists: List lst1, lst2; lst1.push_front( 35 ); lst1.push_front( 18 ); lst2.push_front(
Announcements You will receive your scores back for Assignment 2 this week. You will have an opportunity to correct your code and resubmit it for partial.
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.
Function: Declaration
CS 215 Final Review Ismail abumuhfouz Fall 2014.
ENEE150 Discussion 13 Section 0101 Adam Wang.
COS 126 – Atomic Theory of Matter
Stack Data Structure, Reverse Polish Notation, Homework 7
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Edge Detection The purpose of Edge Detection is to find jumps in the brightness function (of an image) and mark them.
Discussion section #2 HW1 questions?
Basic C++ What’s a declaration? What’s a definition?
COS 126 – Atomic Theory of Matter
COS 126 – Atomic Theory of Matter
Arrays versus ArrayList
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
COP 3330 Object-oriented Programming in C++
Data Structures & Algorithms
EE 312 Final Exam Review.
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
SPL – PS1 Introduction to C++.
Presentation transcript:

CSCI 103 – 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 data type 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.h, blob.cpp API for representing particles (blobs) in water Blob() void add(int i, int j) int mass() // number of pixels double distance_to(Blob b) // from center (average) string to_string() 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.h, blob.cpp Challenges Write your own thorough tests (test_blob.cpp) Add header guards to blob.h to avoid linker errors: #ifndef BLOB_H #define BLOB_H … your declaration of class Blob {…}; #endif Use ostringstream to implement to_string() Center of mass, and # of pixels

blobfinder.h, blobfinder.cpp Locate all blobs in a given image And identify large blobs (called beads) API BlobFinder(Picture picture, double threshold) Calculate luminance Include pixels with a luminance >= threshold Use the luminance formula in assignment Find blobs with DFS The hard part, next slide… This constructor should build a vector of all Blobs in picture vector get_beads(int minSize) Returns all “beads:” Blobs with at least minSize pixels vector must be of size equal to number of beads

BlobFinder - Depth First Search Use boolean 2D vector 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 2D vector 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 2D vector 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 2D vector 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 2D vector 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 2D vector 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 members? vector of Blobs for sure Variables to facilitate DFS? 2D vector of bool for “visited” Either store as data member, or declare as local to constructor and pass by pointer/reference to recursive function Other variables involved in recursive DFS should be treated similarly Don’t try to mimic BFS too closely No Location, Itinerary, predecessor necessary

beadtracker.cpp 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./beadtracker run_1/*.jpg Expands files in alphabetical order End up as argv[4], argv[5], … Avoiding memory issues Don’t use new or delete at all Avoid opening > 2 Pictures at once Recompiling Recompile if Blob or BlobFinder change

avogadro.cpp 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 Blobs or vectors passed into/out of functions may get copied (pass-by-value) Use data member, pointer or reference Common errors Segfault from stack overflow: no base case Out of bounds: use.at() and valgrind Use test_blobfinder as soon as possible Look at checklist Q&A