C OMPUTATIONAL A SPECTS OF C OMPUTATIONAL D IGITAL P HOTOGRAPHY P - - PowerPoint PPT Presentation

c omputational a spects of
SMART_READER_LITE
LIVE PREVIEW

C OMPUTATIONAL A SPECTS OF C OMPUTATIONAL D IGITAL P HOTOGRAPHY P - - PowerPoint PPT Presentation

CS 89.15/189.5, Fall 2015 C OMPUTATIONAL A SPECTS OF C OMPUTATIONAL D IGITAL P HOTOGRAPHY P HOTOGRAPHY Assignment 0: C++ Refresher Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu First programming assignment Programming assignment 0 available


slide-1
SLIDE 1

Assignment 0: C++ Refresher

COMPUTATIONAL ASPECTS OF DIGITAL PHOTOGRAPHY

Wojciech Jarosz wojciech.k.jarosz@dartmouth.edu

COMPUTATIONAL PHOTOGRAPHY

CS 89.15/189.5, Fall 2015

slide-2
SLIDE 2

CS 89/189: Computational Photography, Fall 2015

First programming assignment

Programming assignment 0 available on class website

  • just a warm up
  • familiarize yourself with C++ and the basecode
  • compile
  • change brightness/contrast of an image

2

slide-3
SLIDE 3

C++

slide-4
SLIDE 4

CS 89/189: Computational Photography, Fall 2015

Why C++?

More efficient than Java (compilation, memory)

  • Ridiculously more efficient than Python

Standard language for many domains where performance matters (graphics, imaging) Good experience

4 Modeled after a slide by Frédo Durand

slide-5
SLIDE 5

CS 89/189: Computational Photography, Fall 2015

Online resources

http://cs.brown.edu/courses/cs123/docs/ java_to_cpp.shtml http://www.cprogramming.com/java/c-and-c++-for- java-programmers.html http://www.horstmann.com/ccj2/ccjapp3.html and many more…

5 Modeled after a slide by Frédo Durand

slide-6
SLIDE 6

Images in C++

slide-7
SLIDE 7

CS 89/189: Computational Photography, Fall 2015

Digital images

Can be encoded as 3D arrays

  • 2D (x,y) grid of pixels
  • for each (x,y), have a number of channels (e.g. R, G, B)

Formally:

  • Domain: 2D plane
  • Range: RGB space

Other color spaces possible Values often encoded as 8- or 16-bit integers ([0..255] or [0..65535])

  • But we will use floats in [0..1] to make life simpler

7 Modeled after a slide by Frédo Durand

slide-8
SLIDE 8

CS 89/189: Computational Photography, Fall 2015

Arrays

C++ vector

  • dynamically sized
  • templatized by type, float in our case
  • e.g.: data = std::vector<float>(size, initialValue);

Array3D (array3d.h)

  • our templatized wrapper to access a C++ vector as a 3D

array

8 Modeled after a slide by Frédo Durand

slide-9
SLIDE 9

vectors only have one 1D index turn 2D index into 1D through strides

  • pixel at x,y stored at y*width + x

CS 89/189: Computational Photography, Fall 2015

1D to 2D

9

2D array

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

1D vector encoding

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Modeled after a slide by Frédo Durand

slide-10
SLIDE 10

vectors only have one 1D index likewise for 3D where z is the color channel

  • pixel at x,y,z stored at z*width*height + y*width + x
  • other choices possible, e.g. y*width*depth + x*depth + z
  • why favor one over the other?

3D array

18 19 20 21 22 23 24 25 26 9 10 11 12 13 14 15 16 17

CS 89/189: Computational Photography, Fall 2015

1D to 3D

10

1 2 3 4 5 6 7 8

1D vector encoding

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Modeled after a slide by Frédo Durand

slide-11
SLIDE 11

CS 89/189: Computational Photography, Fall 2015

Our FloatImage class

Inherits from Array3D<float> Stores a vector of pixel values

  • size width*height*numChannels

size & number of dimensions

  • could be used to represent 2D images with single channel,
  • r even 1D arrays

access data using operator(…), e.g.: image(x,y,z)

11

slide-12
SLIDE 12

CS 89/189: Computational Photography, Fall 2015

File formats

We’ll use PNG

  • simple to read, no big library needed
  • only lodepng.(h|cpp) in ext subdirectory
  • easy to convert to/from other formats

We’ll talk about how JPEG and other formats work later

12

slide-13
SLIDE 13

CS 89/189: Computational Photography, Fall 2015

Programming Assignment 0

Just a warm up familiarize yourself with C++, the FloatImage class compile change brightness & contrast of an image

13

slide-14
SLIDE 14

CS 89/189: Computational Photography, Fall 2015

Next…

History of photographic technology

14

slide-15
SLIDE 15

CS 89/189: Computational Photography, Fall 2015

Slide credits

Frédo Durand

15