E-LEARNING IN JUNIOR COLLEGES RJ111 chenhe leducanh wangjunlem wongzhiyuan.
Stereogram Generation Workshop - comp.nus.edu.sgbleong/stereo/StereogramWorkshop.pdf · 1 NUS...
Transcript of Stereogram Generation Workshop - comp.nus.edu.sgbleong/stereo/StereogramWorkshop.pdf · 1 NUS...
1
NUS Computing Camp for NUS Computing Camp for Junior Colleges & Junior Colleges & High School StudentsHigh School Students
Stereogram Stereogram Generation WorkshopGeneration Workshoppp
Dr Ben LeongDr Ben LeongNUS School of ComputingNUS School of Computing
28 Nov 201228 Nov 2012
What are stereograms?What are stereograms?
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 perceiveThese differences allow us to perceive 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 depthof depth
How do stereograms work?How do stereograms work?
Image plane
A BC D
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 3Create a 3--d model of the objectd 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
22 Decide on some parametersDecide on some parameters2.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
2
Generation of stereogramsGeneration of stereograms
Image plane
Generation of stereogramsGeneration of stereograms
Image plane
Generation of stereogramsGeneration of stereograms
Image plane
How far?
Generation of stereogramsGeneration of stereograms
Image plane
AD
-z
E
s
zD
E
z
s
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 depthWhat you need to do is to create a depth 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
3
Plan for TodayPlan for Today
You 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 you
Create Create cool stereogramscool stereograms and and share with your friends and familyshare with your friends and family
Primitive building blocksPrimitive building blocks
(show rcross(show rcross--bb)bb)
Primitive building blocksPrimitive building blocks
(show corner(show corner--bb)bb)
Primitive building blocksPrimitive building blocks
(show sail(show sail--bb)bb)
Primitive building blocksPrimitive building blocks
(show nova(show nova--bb)bb)
Primitive building blocksPrimitive building blocks
(show heart(show heart--bb)bb)
4
Primitive building blocksPrimitive building blocks
(show circle(show circle--bb)bb)
Primitive building blocksPrimitive building blocks
(show spiral(show spiral--bb)bb)
Primitive Operation:Primitive Operation:Rotating to the RightRotating to the Right
(clear)(clear)
(show (quarter(show (quarter--turnturn--right sailright sail--bb))bb))
Derived Operation:Derived Operation:Rotating Upside DownRotating Upside Down
(clear)(clear)
(show (turn(show (turn--upsideupside--down saildown sail--bb))bb))
How about How about Rotating to the Left?Rotating to the Left?
(clear)(clear)
(show (turn(show (turn--quarterquarter--left sailleft sail--bb))bb))
Flipping ObjectsFlipping Objects
(clear)(clear)
(show (flip(show (flip--horiz novahoriz nova--bb))bb))
(clear)(clear)
(show (flip(show (flip--vert novavert nova--bb))bb))(show (flip(show (flip--vert novavert nova--bb))bb))
5
Means of Combination:Means of Combination:StackingStacking
(clear)(clear)
(show (stack rcross(show (stack rcross--bb sailbb sail--bb))bb))
Multiple StackingMultiple Stacking
(clear)(clear)
(show (stack rcross(show (stack rcross--bb bb
(stack rcross(stack rcross--bb sailbb sail--bb)))bb)))
Placing objects one beside Placing objects one beside the otherthe other
(clear)(clear)
(show (beside sail(show (beside sail--bb rcrossbb rcross--bb))bb))
A complex objectA complex object
(clear)(clear)
(show(show
(stack(stack
(beside(beside(beside (beside
(quarter(quarter--turnturn--right rcrossright rcross--bb)bb)
(turn(turn--upsideupside--down rcrossdown rcross--bb))bb))
(beside (beside
rcrossrcross--bbbb
(quarter(quarter--turnturn--left rcrossleft rcross--bb))))bb))))
This operation is also known asThis operation is also known asmakemake--crosscross
Naming your objects with defineNaming your objects with define
(clear)(clear)
(define myPic (define myPic
(make(make--cross sailcross sail--bb))bb))
(show myPic)(show myPic)
(define myPic2 (define myPic2
(make(make--cross novacross nova--bb))bb))
(show myPic2)(show myPic2)
Repeating the patternRepeating the pattern
(clear)(clear)
(show (make(show (make--cross (makecross (make--cross novacross nova--bb)))bb)))
6
Repeating multiple timesRepeating multiple times
(clear)(clear)
(show (repeat(show (repeat--pattern 4 makepattern 4 make--cross novacross nova--bb))bb))
What about 3 rows?What about 3 rows?(clear)(clear)
(show (stack(show (stack--frac 1/3 rcrossfrac 1/3 rcross--bb sailbb sail--bb))bb))
(clear)(clear)
(show (stack(show (stack--frac 1/3 rcrossfrac 1/3 rcross--bbbb
(stack rcross(stack rcross--bb rcrossbb rcross--bb)))bb)))
Repeating n timesRepeating n times
(clear)(clear)
(show (stackn 3 nova(show (stackn 3 nova--bb))bb))
(clear)(clear)
(show (stackn 5 nova(show (stackn 5 nova--bb))bb))(show (stackn 5 nova(show (stackn 5 nova bb))bb))
A rectangular repeated patternA rectangular repeated pattern
(clear)(clear)
(show (stackn 5 (quarter(show (stackn 5 (quarter--turnturn--right right
(stackn 5 (quarter(stackn 5 (quarter--turnturn--left novaleft nova--bb)))))bb)))))
Another regular patternAnother regular pattern
(clear)(clear)
(show (nxn 3 (make(show (nxn 3 (make--cross rcrosscross rcross--bb)))bb)))
Creating 3D objects Creating 3D objects
We use greyscale to represent depthWe use greyscale to represent depth Black is nearest to youBlack is nearest to you
White is furthest awayWhite is furthest away
means
7
Creating 3D objectsCreating 3D objects
means
Overlay OperationOverlay Operation
(clear)(clear)
(show (overlay sail(show (overlay sail--bb rcrossbb rcross--bb))bb))
Advanced Overlay OperationAdvanced Overlay Operation
(clear)(clear)
(show (overlay(show (overlay--frac 1/4 cornerfrac 1/4 corner--bb heartbb heart--bb))bb))
ScalingScaling
(clear)(clear)
(show (scale 1/2 heart(show (scale 1/2 heart--bb))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(show (overlay sail--bb rcrossbb rcross--bb))bb))
(stereogram (stereogram
(overlay sail(overlay sail--bb rcrossbb rcross--bb))bb))
Your First StereogramYour First Stereogram
8
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(load--map <filename>)map <filename>)
You can save your work with:You can save your work with:(save <filename>)(save <filename>)
What if you What if you cannot seecannot seecannot see cannot see
stereograms? stereograms?
Think DifferentThink Different
Image plane
Think DifferentThink Different
Image plane
Think DifferentThink Different
Image plane
3D Anaglyphs3D Anaglyphs
Image plane
Use filters to show one image to each eye!Use filters to show one image to each eye!
9
What else can we What else can we do to create ando to create ando to create an do to create an illusion of 3D? illusion of 3D?
Simulating 3D Effect with AnimationSimulating 3D Effect with Animation
Image plane
Simulating 3D Effect with AnimationSimulating 3D Effect with Animation
Image plane
Simulating 3D Effect with AnimationSimulating 3D Effect with Animation
Image plane
Simulating 3D Effect with AnimationSimulating 3D Effect with Animation
Image plane
10
Simulating 3D Effect with AnimationSimulating 3D Effect with Animation
Image plane
Simulating 3D Effect with AnimationSimulating 3D Effect with Animation
Image plane
Simulating 3D Effect with AnimationSimulating 3D Effect with Animation
Image plane
QUESTIONSQUESTIONS What you have What you have seen are the seen are the
basics of basics of programming! programming!
11
The World of Computer ScienceThe World of Computer Science
Artificial IntelligenceLogic
G hi
Vision
Human-Computer InteractionProgramming Languages
Programming
Database
Data Structures & AlgorithmsCompilers
Graphics
Software EngineeringTheory
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 marketthe marketFigure out what you like and what Figure out what you like and what
you’re good atyou’re good at –– and keep doing itand keep doing ityou re good at you re good at and keep doing itand 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?