gtso86 / computational-photography

Workshop materials for the Computational Photography workshop at the Anderson ranch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Computational Photography

Hello! These are the materials for the computational photography workshop taught by Adam Ferriss (aferriss@gmail.com) at the Anderson Ranch summer of 2020.

Table of Contents

Schedule

*The schedule may change depending on the pace and needs of the class!

Meeting Times

July 27 - 31

The below times are in MST

9am - 11am Class time and demos

11am - 1pm Lunch

1pm - 4pm Class time and individual meetings

Day 1 - Monday July 27

  • Introductions
  • Workshop Overview
  • Setting up your environment
  • p5 image function demos
    • loadImage()
    • image()
    • get()
    • set()
    • copy()
  • exporting your work

Day 2 - Tuesday July 28

  • Pixel Part 1
    • looping over pixel array
    • accessing individual pixels
    • pixels as data

Day 3 - Wednesday July 29

  • Pixels Part 2
    • Kernel Convolution demo
  • Shaders Part 1
    • Shader Syntax
    • Texture2D
    • Shader functions smoothstep(), step(), clamp(), mix()

Day 4 - Thursday July 30

  • Shaders Part 2
    • UV fun (wiggle, distort, displacement)
    • Shader convolution
  • Multipass rendering
    • Feedback

Day 5 - Friday July 31

  • Going further
  • Work Share / Critique

What is Computational Photography?

black hole

Computational Photography is actually a pretty broad term but for the purposes of this class, I am taking it to mean any method by which a photograph or digital image can be manipulated via code.

In the broader definition, it refers to imaging techniques that expand the capability of digital cameras / sensors through the use of software. A lot of this tech was made for our phones. Think of portrait mode on iPhones or Google's night sight on Androids. Newer techniques using machine learning have also been deployed for things like upscaling small images, removing noise and artifacts, or extracting 3d depth information from single photographs. We'll look at some of these new advances in the course of this workshop.

Workshop Format

We'll be meeting on zoom every morning from 9am - 11am for live coding demos of new techniques. We'll have a short break for lunch and then return in the afternoon at 1pm. Depending on the day, we will likely do a combination of individual meetings and demos in the afternoon, ending at 4pm.

On Friday we'll all get together to share our work and critique.

What (I hope) you'll get out of it

My hope is that you take away some of the core techniques for learning how to manipulate images with code. Hopefully these are processes that will help further your own artistic practice and expand your tool set for artistic expression / ideation. What you produce here is up to you. If you want to make a suite of new tools for your own practice, great! If you want to just sit back and soak it in and experiment with the examples I provide, that's totally fine too!

I'll be leaving this repo up as a resource for you and the general public for as long as I can so hopefully it is something you can return to for guidance or help for as long as you need it.

I'm here to help you as much as I can so please don't hesitate to reach out if you need help or even just wanna chat (e-mail is great but we can talk about setting up a slack or discord if people are interested). Also reach out to your fellow workshop-mates. We're only together for a short time but we can all learn from each other during this week.

Lastly, I encourage you to consider the ways in which computational photography (and code based image making in general) might cause harm in the world (ex. face recognition used for surveillance by an authoritarian govt). What can we use these technologies for that will move the needle in the direction of racial, social, and ecological justice?

Code of Conduct

This code of conduct was borrowed from the p5.js code of conduct but the same tenets apply in this workshop.

  • Be mindful of your language. Any of the following behavior is unacceptable:

    • Offensive comments related to gender identity and expression, sexual orientation, race, ethnicity, language, neuro-type, size, ability, class, religion, culture, subculture, political opinion, age, skill level, occupation, or background
    • Threats of violence
    • Deliberate intimidation
    • Sexually explicit or violent material that is not contextualized and preceded by a considerate warning
    • Unwelcome sexual attention
    • Stalking or following
    • Or any other kinds of harassment

    Use your best judgement. If it will possibly make others uncomfortable, do not post it.

  • Be respectful. Disagreement is not an opportunity to attack someone elses thoughts or opinions. Although views may differ, remember to approach every situation with patience and care.

  • Be considerate. Think about how your contribution will affect others in the community.

  • Be open minded. Embrace new people and new ideas. Our community is continually evolving and we welcome positive change.

Setting up your coding environment

If you're just learning to code, or just want to get started quickly, I strongly recommend that you use the p5.js code editor which can be found at https://editor.p5js.com. Be sure to make an account, otherwise you won't be able to save your sketches or upload images. You can always download your code and move it to another environment later if you don't like the online editor.

However, if you'd like to branch out and explore other options, I recommend you download VSCode. Along with VSCode you may want to download some extensions. I've listed a few of the ones I use below in the resource section, but of particular note is the VSCode live share extension. This may be useful so that we can code together during one on one sessions. The live server extension is also really handy for spinning up a localhost server (which you will need to use images) from within VSCode.

If you opt to use VSCode, I've also provided a template p5.js project for you to start with. It also includes the typescript file so that code auto-completion will work out of the box. Just be sure to duplicate the template whenever you want to start a new sketch.

In Class demo code

Monday

Tuesday

Wednesday

Thursday

Friday

Code Examples

I have created this collection of code example sketches for your reference. Most of them should be pretty well commented but if you've got questions about how anything is working, let me know!

Everything below is arranged from least complex to most complex

Image functions

loadImage() and image()

Loading and drawing an image

drawing an image

Resizing an image

resized

Drawing images at different sizes

multiple sizes

Using an image as a brush

image brush

Grid of images

grid of images

filter()

Posterize

posterize

Blur

blur

Threshold

threshold

Invert

invert

get()

Image as lines

image as lines

Concentric Rings

concentric rings

Pixelate

pixelated

Grid of circles

grid of circles

Random pixel walkers

pixel walkers

Image chopper - Multiple Layers

chopper

set()

Threshold

threshold

copy()

Slicer-upper vertical

slicer vertical

Slicer-upper vertical and horizontal

slicer both dir

Pixel Stretch Brush

pixel stretch brush

Pixel Line brush

pixel line brush

Image offset brush

image offset brush

Feedback

feeback

Offset glitchy grid

glitchy grid

pixels array

Single Pixel Sample

pixel sample

Invert Color

invert

Invert Color - Feedback Brush

invert brush

Color Sampling Brush

color sample brush

Random Colors

random colors

Average color

average color

Looping through pixels - multiple ways

pixel loops

Convolution - Sharpen Brush

sharpen brush

Convolution - Emboss Feedback Brush

emboss brush

Shaders

Simple Red Shader

simple red

Mouse Uniforms

mouse uniforms

Passing Uv's

passing uvs

Texture 2D

texture2D

Texture 2D - Offset

Tex2d offset

Texture 2D - Scale

Texture 2D Scale

Texture Wrap

texture wrap

Invert Colors

invert

Wiggle Distort

Wiggle

Brightness and Contrast

brightness and contrast

Smoothstep Threshold

Smooth thresh

Chromatic Aberration

chroma aberrate

Pixelate

Pixelate

Mix two images

mix

Displacement

displacement

Blur

blur

Emboss Convolution

emboss

save() and exporting work

Save on keypress

Save on button press

Resources

Pixels

Shaders

Javascript / p5

Environment and Code Editor

  • VS Code
  • Workflow: Visual Studio Code
  • Prettier is a great code style guide / auto formatter. It also helps bring everyone's code into the same style which makes it easier to debug when reading code other people have written.
  • Shader Language Support is super helpful for syntax highlighting when working with GLSL or other shader languages.
  • Live Server adds a localserver to VSCode so you can preview your sketches without having to do any work to set up a localhost. Just click the Go Live button on the blue bar on the bottom right to start which should open up a web page at localhost:5500
  • p5 Types is a typescript definitions file for p5.js. It is already included in the template I've prepared for you but if you plan to continue working in VSCode I highly recommend picking this up. This will give you autocomplete support when working with p5 in VSCode. You can just copy the global.d.ts file into your project folder and then on the first line of your sketch add: /// <reference path="./global.d.ts" />
  • Bracket Pair Colorizer is a little addon that makes it a little easier to tell which brackets belong to which by coloring the opening { and closing } the same color

Books

  • Generative Design is an excellent book with tons of code examples for getting your feet wet with generative design. The book now comes with p5.js examples too!
  • Getting Started with p5.js by Lauren McCarthy and Casey Reas is a great and quick primer for jumping into p5.js. I've often used this book for teaching and think it's one of the most friendly and approachable books for learning to code.
  • Learning Processing by Daniel Shiffman is the book that I first read when learning to code. Super clear examples and covers just a tad of everything you need to get started with processing / p5.
  • The Nature of Code is Daniel Shiffman's follow up to Learning Processing. It looks at patterns in nature as inspiration for processing sketches and goes into some deeper topics like AI and emergence behavior.

About

Workshop materials for the Computational Photography workshop at the Anderson ranch


Languages

Language:HTML 63.0%Language:JavaScript 37.0%