![Page 1: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/1.jpg)
CS 248 Assignment 1Paint Program
Introduction to Computer Graphics Help SessionIntroduction to Computer Graphics Help Sessionslides by Georg slides by Georg PetschniggPetschniggModified and presented by Rene Modified and presented by Rene PatnodePatnodeStanford UniversityStanford UniversityOctober 4, 2002October 4, 2002
![Page 2: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/2.jpg)
2
Session Overview
•• Getting StartedGetting Started•• Assignment DiscussionAssignment Discussion
• Overpainting Brush
• Tinting Brush
• Brush Visualization
•• Grading DetailsGrading Details•• Extra CreditExtra Credit•• QuestionsQuestions
![Page 3: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/3.jpg)
3
Getting Started
1.1. Read assignment carefully and pay Read assignment carefully and pay attention to the details.attention to the details.
2.2. Go to review sessionGo to review session3.3. Familiarize yourself with Raptor/Firebird Familiarize yourself with Raptor/Firebird
Lab Located in the Basement of Sweet Lab Located in the Basement of Sweet HallHall
![Page 4: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/4.jpg)
4
Development Environment
•• Ways to work with TA SupportWays to work with TA Support• Go to Sweet Hall (Best Way – 5 Minutes)
• Work Remotely (Good Way – 5 Minutes)
•• Ways to work without TA supportWays to work without TA support• Reproduce Sweet Hall Lab development
environment on you own Machine (1 Hour)
• Your code still has to work on the Sweet Hall machines (more risk for you)
![Page 5: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/5.jpg)
5
Sweet Hall
1. Pick a free computer, Log on
2. Copy assignment from usr/class/cs248/assignments/assignment1/
to local directory
3. Run ‘make’
4. Run ‘./paint.i386-linux’
![Page 6: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/6.jpg)
6
Working Remotely
1. ssh to firebird, raptor or leland
2. Export the display (using e.g. Exceed)
3. Follow instructions on previous slide
>ssh raptor.stanford.edu>setenv DISPLAY yourIP:0.0>xterm &
![Page 7: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/7.jpg)
7
Assignment Discussion
•• You are going to write a paint programYou are going to write a paint program• Teaches you 2D Raster Graphics
• Visualize concepts learned in Class (Brushes, HSV)
• This assignment is a lot of fun
• Be creative with extra credit
•• The next slides follow the Assignment The next slides follow the Assignment (Handout #3) step by step(Handout #3) step by step• Reminder: Read the assignment
![Page 8: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/8.jpg)
8
Part 1: Over Painting Brush
•• Rectangular Rectangular OverpaintingOverpainting BrushBrush• Like Microsoft Paint or “Pencil Tool” in PhotoShop
•• Color Picker for RGB, HSVColor Picker for RGB, HSV• See http://www.ewertb.com/java/Java_ColorPicker.html or any
commercial Paint Program• Value (1.0 bright, 0.0 black)• Saturation
(1.0 strong hue, 0.0 faded hue)
•• Size Control for BrushSize Control for Brush
Demo: Painting, Picking Colors in PhotoShop Demo: Painting, Picking Colors in PhotoShop
![Page 9: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/9.jpg)
9
Part 1: Basic Painting Loop
Brush region
Brush region
![Page 10: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/10.jpg)
10
Part 1: Over Painting Brush
•• Once you are done with Part 1 you should Once you are done with Part 1 you should be able to draw some basic imagesbe able to draw some basic images
•• Notice the hard edges and Notice the hard edges and jaggiesjaggies around around the stroke… this is what Part 2 will fixthe stroke… this is what Part 2 will fix
![Page 11: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/11.jpg)
11
Part 2: Tinting Brush
•• Implement Weighted Mask Driven Brush Implement Weighted Mask Driven Brush as described in Handout #4as described in Handout #4• Instead of a rectangular brush, have it gently
“blend” to its surroundings. Use HSV interpolation
•• Checkboxes for interpolating along H,S,V Checkboxes for interpolating along H,S,V axis axis • Allow all permutations HSV, HS, HV, SV, H, S, V
•• Choose a mask function an give use Choose a mask function an give use control over itcontrol over it• Make sure it gradually falls of to zero at the edge!
![Page 12: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/12.jpg)
12
Part 2: Weighted Blending
Like painting with partially transparent paint. Like painting with partially transparent paint. Commonly referred to as “alpha” blending.Commonly referred to as “alpha” blending.
Cnew = (1-α) Cold + α Cpaint
Compositing equationCompositing equation
α
![Page 13: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/13.jpg)
13
Part 2: Mask driven painting
Lookup array determines how each pixel in the Lookup array determines how each pixel in the brush is affected.brush is affected.
Paint every pixel in the brush region
Paint only some of the pixels
![Page 14: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/14.jpg)
14
Part 2: Weighted mask driven painting
Mask contains alpha/weight for each pixel in brushMask contains alpha/weight for each pixel in brush
![Page 15: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/15.jpg)
15
Part 2: RGB vs. HSV interpolation
NewRNewR = (1= (1--αα) ) CanvasRCanvasR + + αα PaintRPaintRNewGNewG = (1= (1--αα) ) CanvasGCanvasG + + αα PaintGPaintGNewBNewB = (1= (1--αα) ) CanvasBCanvasB + + αα PaintBPaintB
NewHNewH = (1= (1--αα) ) CanvasHCanvasH + + αα PaintHPaintHNewSNewS = (1= (1--αα) ) CanvasSCanvasS + + αα PaintSPaintSNewVNewV = (1= (1--αα) ) CanvasVCanvasV + + αα PaintVPaintV
RGBRGB interpolationinterpolation
HSV interpolationHSV interpolation
![Page 16: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/16.jpg)
16
Hue
Sat
urat
ion
Part 2: RGB vs. HSV interpolation
![Page 17: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/17.jpg)
17
Hue
Sat
urat
ion HSV
RGB
Part 2: RGB vs. HSV interpolation
![Page 18: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/18.jpg)
18
Part 2: Math Example
•• Interpolating half way between Red and Interpolating half way between Red and Cyan (Cyan (αα = 0.5)= 0.5)
•• NewColorNewColor = 0.5 Cyan + 0.5 Red= 0.5 Cyan + 0.5 Red
9090
00
180180
HH
1.01.01.01.00.50.50.50.50.50.5InterpolationInterpolation
1.01.01.01.00.00.00.00.01.01.0RedRed
1.01.01.01.01.01.01.01.00.00.0CyanCyan
VVSSBBGGRR
50% Gray Greenish
![Page 19: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/19.jpg)
19
Part 2: HSV Checkboxes
•• Choose which HSV components to affect.Choose which HSV components to affect.•• Allow for any combination.Allow for any combination.
if (H_check) { NewH = (1-α) CH + α PaintH }if (S_check) { NewS = (1-α) CS + α PaintS }if (V_check) { NewV = (1-α) CV + α PaintV }
![Page 20: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/20.jpg)
20
Part 2: Sample Images
Image showing H, S, and V Tinting
Overpainting #1 vs. Weighted Mask
driven painting #2
![Page 21: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/21.jpg)
21
Part 3: Brush Visualization
•• Brush Visualization should tell user what Brush Visualization should tell user what its color, falloff and size isits color, falloff and size is• Brush should always be visible regardless of color
• Draw 1x (actual size) and 4x (four times larger in x and y) versions of the brush
• Make the larger version discretized – that is it should be a choppy/chunky/pixel replicated version of the actual brush (think xmag, snoop)
• Make sure this visualization will help you explain to user, TAs, Professor and yourself how the brush weights affect drawing
![Page 22: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/22.jpg)
22
Requirements
•• Correctness (40%)Correctness (40%)• Don’t crash
• Implement all required features
• (Read the directions like a lawyer)
•• Efficiency (20 %)Efficiency (20 %)• No noticeable lag while using your application
•• User Interface (20%)User Interface (20%)•• Programming Style (20%)Programming Style (20%)
• Copying code (Don’t do it)
•• Submitting with ‘/usr/class/cs248/bin/submit’Submitting with ‘/usr/class/cs248/bin/submit’
![Page 23: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/23.jpg)
23
Paint Program 1973
Source: Dick Shoup “SuperPaint: An Early Frame Buffer Graphics System” IEEE Annals of the History of Computing, Vol 23, No 2, Apr-Jun 2001
![Page 24: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/24.jpg)
24
Extra credit example
Blurring the image under the brush.Blurring the image under the brush.
![Page 25: CS 248 Assignment 1 Paint Program - Computer Graphicsgraphics.stanford.edu/.../proj1help/assignment1help.pdf · 2003-10-05 · Assignment Discussion • You are going to write a paint](https://reader033.vdocuments.us/reader033/viewer/2022050314/5f76d7eec289601cca7fd63c/html5/thumbnails/25.jpg)
25
Questions?
•• Ask nowAsk now•• Come to Office HoursCome to Office Hours•• Email: Email: [email protected]@lists.stanford.edu
•• Remember: Computer Graphics is fun Remember: Computer Graphics is fun -- if if you are not having fun ask TAs for helpyou are not having fun ask TAs for help