function

>>> def cylinder_volume(height, radius):
	pi = 3.14159
	return height * pi * radius ** 2

>>> cylinder_volume(10, 3)
282.7431
def population_density(population, land_area):
    return population / land_area

test1 = population_density(10, 1)
expected_result1 = 10
print("expected result: {}, actual result: {}".format(expected_result1, test1))

test2 = population_density(864816, 121.4)
expected_result2 = 7123.6902801
print("expected result: {}..., actual result: {}".format(expected_result2, test2))
def readable_timedelta(days):
    week = days / 7
    day = days % 7
    return "{} week(s) and {} day(s)".format(week, day)
    
print(readable_timedelta(120))

Type and Type conversion

>>> print(type(633))

>>> print(type("633"))

>>> print(type(633.0))

mon_sales = 121
tues_sales = 105
wed_sales = 110
thurs_sales = 98
fri_sales = 95
total = str(mon_sales + tues_sales + wed_sales + thurs_sales + fri_sales)
print("This week\'s total sales: " + total)

python string method
https://docs.python.org/3/library/stdtypes.html#string-methods

prophecy = "And there shall in that time be rumours of things going astray, and there will be a great confusion as to where things really are, and nobody will really know where lieth those little things with the sort of raffia work base, that has an attachment…at this time, a friend shall lose his friends’s hammer and the young shall not know where lieth the things possessed by their fathers that their fathers put there only just the night before around eight o’clock…"

vowel_count = 0
vowel_count += prophecy.count('a')
vowel_count += prophecy.count('A')
vowel_count += prophecy.count('e')
vowel_count += prophecy.count('E')
vowel_count += prophecy.count('i')
vowel_count += prophecy.count('I')
vowel_count += prophecy.count('o')
vowel_count += prophecy.count('O')
vowel_count += prophecy.count('u')
vowel_count += prophecy.count('U')

print(vowel_count)

format

log_message = "IP address {} accessed {} at {}".format(user_ip, url, now)

city = "Seoul"
high_temperature = 18
low_temperature = 9
temperature_unit = "degrees Celsius"
weather_conditions = "light rain"

alert = "Today's forecast for {}: The temperature will range from {} to {}{}. Conditions will be {}.".format(city, high_temperature, low_temperature, temperature_unit, weather_conditions)
# print the alert
print(alert)

Changing Variable

>>> manila_pop = 1780148
>>> manila_area = 16.56
>>> manila_pop_density = manila_pop/manila_area
>>> print(int(manila_pop_density))
107496

bool

>>> 1 < 2
True
>>> 42 > 43
False
sf_population, sf_area = 864816, 231.89
rio_population, rio_area = 6453682, 486.5

san_francisco_pop_density = sf_population/sf_area
rio_de_janeiro_pop_density = rio_population/rio_area

print(san_francisco_pop_density > rio_de_janeiro_pop_density)

string

>>> print("hello")
hello
>>> print('hello')
hello
>>> welcome_message = "Hello, welcome to Tokyo"
>>> print(welcome_message)
Hello, welcome to Tokyo
>>> instructor_1 = "Philip"
>>> instructor_2 = "Charlie"
>>> print(instructor_1 + " and " + instructor_2)
Philip and Charlie
messiah = 'He\'s not the Messiah, he\'s a very naughty boy!'
print(messiah)

username = "Kinari"
timestamp = "04:50"
url = "http://petshop.com/pets/mammals/cats"
print(username + " accessed the site " + url + " at " + timestamp)

len

>>> tokyo_length = len("Tokyo")
>>> print(tokyo_length)
5

given_name = "Charlotte"
middle_names = "Hippopotamus"
family_name = "Turner"

name_length = len(given_name+middle_names+family_name)

driving_licence_character_limit = 28
print(name_length <= driving_licence_character_limit) [/python]

Arithmetic

Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> print(3+1)
4
>>> 3 + 1
4
>>> print(1 + 2 + 3 * 3)
12
>>> print((1 + 2 + 3) * 3)
18
>>> print(3**2)
9
>>> print(9 % 2)
1
>>> print(15 // 4)
3
>>> print(16 // 4)
4
>>> print(-5 // 4)
-2
>>> print((23 + 32 + 64)/ 3)
39

integer and floats

>>> print(3/4)
0
>>> print(16/4)
4
>>> 3 + 2.5
5.5
>>> 213.13
213.13
>>> 341.
341.0
>>> int(49.7)
49
>>> int(16/4)
4
>>> float(3520+3239)
6759.0
>>> print(0.1)
0.1
>>> print(0.1 + 0.1 + 0.1)
0.3

float e.g.
Length of a fish you caught, in metres
Length of time it took to catch the first fish, in hours

4.445e8 is equal to 4.445 * 10 ** 8 which is equal to 444500000.0.

# The current volume of a water reservoir (in cubic metres)
reservoir_volume = 4.445e8
# The amount of rainfall from a storm (in cubic metres)
rainfall = 5e6

# decrease the rainfall variable by 10% to account for runoff
rainfall *= 0.9
# add the rainfall variable to the reservoir_volume variable
reservoir_volume += rainfall
# increase reservoir_volume by 5% to account for stormwater that flows
reservoir_volume *= 1.05 
# into the reservoir in the days following the storm

# decrease reservoir_volume by 5% to account for evaporation
reservoir_volume *= 0.95
# subtract 2.5e5 cubic metres from reservoir_volume to account for water
# that's piped to arid regions.
reservoir_volume -= 2.5e5
# print the new value of the reservoir_volume variable
print(reservoir_volume)

Panoramic Video Texture

1. Review Video Textures and panoramas
2. Combine Video Textures and panoramas to form panoramic video textures
3. Construct a panorama from video

a video that has been stitched into a single, wide field of view
Video registration
video textures of dynamic regions

map a continuous diagonal slice of the input video volume to the output panorama
restricts boundaries to frames
shears spatial structures across time

Video Textures

1. concept of Video Texture
2. methods used to compute similarity between frames
3. use of similar frames to find transitions to generate Video Textures
4. Finding, Cutting, morphing for Video Textures

compute how similar f1 is to all frames f1, f2, f3 … f90
Compute the Euclidean distance between two frames
Consider two frames, p = {p1, p2, … pn} and q = {q1,q2,…qn}
Similar frames are the ones that would be best to jump to

preserving dynamics with transitions
Video portraits

1. Video stabilization
2. Estimating camera motion
3. smoothing camera paths
4. Rendering stabilized videos
5. Dealing with rolling shutter artifacts
original, stabilized

Optical / in-camera stabilization
– floating lens
– sensor shift
– accelerometer + Gyro

Post-process Stabilization
– removes low-frequency perturbations (large buffer)
1. estimate camera motion
2. stabilize camera path
3. crop and re-synthesize

Motion models translation
– translation in x and y
– 2 DOF
– Still very shaky

Path Smoothing
Goal: Approximate original path with stable one
tripod -> Constant segment
dolly or pan -> Linear segment

CCD vs. CMOS Sensors
amplifer

Difficulty: speed of readout varies across cameras
solution: use multiple motion models and blend using miztextures of Gaussians

Video Processing

1. Relationship between Images and Videos
2. Persistence of vision in playing (and computing) Videos
3. Extend filtering and processing of Images to Videos
4. Tracking points in Videos

Digital Image
numeric representation in two-dimensions (x and y)
referred to as I(x,y) in continuous function from I(i,j) in descrete
Image resolution
expressed as representation of width and Height of the image
Each pixel (picture element) contains light intensities for each value of x and y of I(x,y)

Video Resolution
– expressed as representation of width and height of the image
– usually in aspect ratios of 4*3, 16*9, etc

Foundation observation of why we perceive video
Rational behind the invention of video cameras
muybirdge(1830-1904) used stop-action photographs to study animal motion

Processing/ Filtering Video
– same as with images, just over a video volume
– Can filter in 3D
(x,y,t)
– Motion information is used in video compression
apply to xt- and yt- space
if all pixels from one frame to another frame, different, than it maybe a drastic motion change

same as in images
leverage the fact that features found in one frame may be visible in the next

Photosynth

1. Going beyond panoramas
2. Photo Tourism
3. Photo maps, street, vews, tec.

Photo Tourism => Photo Synth
– snavely, setz, szeliski, “photo tourism” exploring photo collections in 3D, ACM SIGGRAPH, 2006
– photosynth.net Technology prevew (2008-2013)

Scene reconstruction
-position, orientation, and focal length of cameras
-3D position of feature points

Feature detection -> Pairwise feature matching -> Correspondence estimation -> Incremental structure from motion

Structure from motion

Stereo

1. Geometry (Depth structure) in a Scene
2. Stereo
3. Parallax
4. Compute depth from a stereo image pair

Depth (of a scene)
3D scene -> illumination -> optics -> sensor -> processing -> display -> user

Above all, we are interested in capturing a 3D scene with Geometry
Xo,Yo,Zo
Xi = Xo/Zof, Yi=Yo/Zof

Fundamental ambiguity any points along the same ray map to the same point int the image
Perspective Nanishing lines/points
Depth Cues

trimensional
3D scanner for iPhone

Depth Cues
shape from structured light

Shape from x
– perspective, shading, motion, focus, occlusions, objects

"""Make an Anaglyph Image."""

import numpy as np
import cv2

def make_anaglyph(img_left, img_right):
	return np.dstack([img_right, img_right, img_left])

def test_run():
	"""Driver function called by Test Run."""
	img_left = cv2.imread("flowers-left.png", 0)
	img_right = cv2.imread("flowers-right.png", 0)
	cv2.imshow("Left image", img_left)
	cv2.imshow("Right image", img_right)

	img_ana = make_anaglyph(img_left, img_right)
	cv2.imshow("Anaglyph image", img_ana)

High Dynamic Range

1. Dynamic Range
2. Digital cameras do not encode Dyamic Range very well
3. Image Acquisition Pipeline for capturing scene radiance to pixel values
4. Linear and non-linear aspects inherent in the Image Acquisition pipeline
5. Camera Calibration
6. Pixel Values from different Exposure Images are used to render a Radiance map of scene
7. Tone mapping

Dynamic range in Real World
Inside, no lights long exposure
Inside, Incandescent light

Luminance: A photometric measure of the luminous intensity per unit area of light traveling in a given direction. measured in candela per square meter(cd/m^2)

Human static Constrast Ratio 1001 (10^2) -> about 65 f-stops
Human Dynamic constraste Ratio 10000000:1 (10^6:1) -> about 20 f-stops

3D scene -> scene radiance -> lens optics -> sensor irradiance -> shutter -> sensor exposure