Upload
arnold-freeman
View
226
Download
0
Tags:
Embed Size (px)
Citation preview
NUS Computing Camp for NUS Computing Camp for Junior Colleges & High School Students Junior Colleges & High School Students
Stereogram Stereogram Generation WorkshopGeneration Workshop
Dr Ben LeongDr Ben LeongNUS School of ComputingNUS School of Computing
28 Nov 201228 Nov 2012
How do stereograms work?How do stereograms work?
Because there is a small separation Because there is a small separation between our eyes, they perceive slightly between our eyes, they perceive slightly different imagesdifferent images
These differences allow us to perceive These differences allow us to perceive depth. depth.
Autostereograms work by repeating Autostereograms work by repeating patterns in such a way as to give us an patterns in such a way as to give us an illusionillusion of depth of depth
Generation of stereogramsGeneration of stereograms
Key idea: compute the sets of points Key idea: compute the sets of points that are constrained to be of the that are constrained to be of the same coloursame colour
Note that we can compute the Note that we can compute the required image one line at a timerequired image one line at a time
How do we compute these sets? How do we compute these sets? Use simple geometryUse simple geometry
Generation of stereogramsGeneration of stereograms
1.1. Create a 3-d model of the objectCreate a 3-d model of the object Use a function Use a function f(x,y)f(x,y) to define the depth of to define the depth of
an objectan object
2.2. Decide on some parametersDecide on some parameters Distance between eyes and imageDistance between eyes and image Position of object relative to image planePosition of object relative to image plane Distance between the two eyesDistance between the two eyes
3.3. Compute one line at a timeCompute one line at a time
How would YOU create a How would YOU create a stereogram? stereogram?
We have already written the program that We have already written the program that will automatically generate a stereogram will automatically generate a stereogram based on the method described.based on the method described.
What you need to do is to create a depth What you need to do is to create a depth map and feed it to the stereogram map and feed it to the stereogram generator:generator:
STEREOGRAM
GENERATOR
depth map
stereogram
How would YOU create a How would YOU create a stereogram?stereogram?
Our stereogram generator is written in Our stereogram generator is written in SchemeScheme
You will learn how to manipulate You will learn how to manipulate some simple objects to build your some simple objects to build your own depth maps and create your own own depth maps and create your own stereogramsstereograms
Simple programming Simple programming
Plan for TodayPlan for TodayYou will get a worksheet that will You will get a worksheet that will
guide you through what we have guide you through what we have discusseddiscussed
My lab assistants will help youMy lab assistants will help youCreate Create cool stereogramscool stereograms and and
share with your friends and familyshare with your friends and family
Primitive Operation:Primitive Operation:Rotating to the RightRotating to the Right
(clear)(clear)
(show (quarter-turn-right sail-bb))(show (quarter-turn-right sail-bb))
Derived Operation:Derived Operation:Rotating Upside DownRotating Upside Down
(clear)(clear)
(show (turn-upside-down sail-bb))(show (turn-upside-down sail-bb))
How about How about Rotating to the Left?Rotating to the Left?
(clear)(clear)
(show (quarter-turn-left sail-bb))(show (quarter-turn-left sail-bb))
Flipping ObjectsFlipping Objects
(clear)(clear)
(show (flip-horiz nova-bb))(show (flip-horiz nova-bb))
(clear)(clear)
(show (flip-vert nova-bb))(show (flip-vert nova-bb))
Means of Combination:Means of Combination:StackingStacking
(clear)(clear)
(show (stack rcross-bb sail-bb))(show (stack rcross-bb sail-bb))
Multiple StackingMultiple Stacking
(clear)(clear)
(show (stack rcross-bb (show (stack rcross-bb
(stack rcross-bb sail-bb)))(stack rcross-bb sail-bb)))
Placing objects one beside Placing objects one beside the otherthe other
(clear)(clear)
(show (beside sail-bb rcross-bb))(show (beside sail-bb rcross-bb))
A complex objectA complex object
(clear)(clear)
(show(show
(stack(stack
(beside (beside
(quarter-turn-right rcross-bb)(quarter-turn-right rcross-bb)
(turn-upside-down rcross-bb))(turn-upside-down rcross-bb))
(beside (beside
rcross-bbrcross-bb
(quarter-turn-left rcross-bb))))(quarter-turn-left rcross-bb))))
This operation is also known This operation is also known asas make-crossmake-cross
Naming your objects with defineNaming your objects with define
(clear)(clear)
(define myPic (define myPic
(make-cross sail-bb))(make-cross sail-bb))
(show myPic)(show myPic)
(define myPic2 (define myPic2
(make-cross nova-bb))(make-cross nova-bb))
(show myPic2)(show myPic2)
Repeating the patternRepeating the pattern
(clear)(clear)
(show (make-cross (make-cross nova-bb)))(show (make-cross (make-cross nova-bb)))
Repeating multiple timesRepeating multiple times
(clear)(clear)
(show (repeat-pattern 4 make-cross nova-bb))(show (repeat-pattern 4 make-cross nova-bb))
What about 3 rows?What about 3 rows?
(clear)(clear)
(show (stack-frac 1/3 rcross-bb sail-bb))(show (stack-frac 1/3 rcross-bb sail-bb))
(clear)(clear)
(show (stack-frac 1/3 rcross-bb(show (stack-frac 1/3 rcross-bb
(stack rcross-bb rcross-bb)))(stack rcross-bb rcross-bb)))
Repeating n timesRepeating n times
(clear)(clear)
(show (stackn 3 nova-bb))(show (stackn 3 nova-bb))
(clear)(clear)
(show (stackn 5 nova-bb))(show (stackn 5 nova-bb))
A rectangular repeated patternA rectangular repeated pattern
(clear)(clear)
(show (stackn 5 (quarter-turn-right (show (stackn 5 (quarter-turn-right
(stackn 5 (quarter-turn-left nova-(stackn 5 (quarter-turn-left nova-bb)))))bb)))))
Another regular patternAnother regular pattern
(clear)(clear)
(show (nxn 3 (make-cross rcross-bb)))(show (nxn 3 (make-cross rcross-bb)))
Creating 3D objects Creating 3D objects
We use greyscale to represent depthWe use greyscale to represent depthBlack is nearest to youBlack is nearest to youWhite is furthest awayWhite is furthest away
means
Overlay OperationOverlay Operation
(clear)(clear)
(show (overlay sail-bb rcross-bb))(show (overlay sail-bb rcross-bb))
Advanced Overlay OperationAdvanced Overlay Operation
(clear)(clear)
(show (overlay-frac 1/4 corner-bb heart-bb))(show (overlay-frac 1/4 corner-bb heart-bb))
Wait, did we say we’re creating Wait, did we say we’re creating stereograms?stereograms?
Yeah, that’s the easy part!Yeah, that’s the easy part!Do: Do:
(stereogram <depth map>)(stereogram <depth map>)Example:Example:(show (overlay sail-bb rcross-bb))(show (overlay sail-bb rcross-bb))
(stereogram (stereogram
(overlay sail-bb rcross-bb))(overlay sail-bb rcross-bb))
Loading from/Saving to FileLoading from/Saving to File
You can also create a depth map using You can also create a depth map using some paint program and load using:some paint program and load using:
(load-map <filename>)(load-map <filename>)
You can save your work with:You can save your work with:
(save <filename>)(save <filename>)
3D Anaglyphs3D Anaglyphs
Image plane
Use filters to show one image to each eye!Use filters to show one image to each eye!
The World of Computer ScienceThe World of Computer Science
Programming
Database
Artificial IntelligenceLogic
Data Structures & Algorithms
Compilers
Graphics
Vision
Software EngineeringTheory
Human-Computer Interaction
Programming Languages
Architecture
Operating SystemsNetworks
Security
Words of AdviceWords of Advice
Consider Computer Science if:Consider Computer Science if:Like Maths (esp. ‘elegant’ Maths)Like Maths (esp. ‘elegant’ Maths)Like to ‘create’ or build thingsLike to ‘create’ or build thingsWant to make a difference to society in Want to make a difference to society in
the work you dothe work you doYou are impatient and you want to see You are impatient and you want to see
your work out there in the real world in a your work out there in the real world in a hurryhurry
Words of AdviceWords of Advice
Follow your heart, Follow your heart, NOTNOT the market the marketFigure out what you like and what Figure out what you like and what
you’re good at – and keep doing ityou’re good at – and keep doing itTry and explore different thingsTry and explore different thingsAsk yourself: What do you want to Ask yourself: What do you want to
do with your life? WHY?do with your life? WHY?