Project 1 Help Section YuChi Lai Mohamed Eldawy

  • Slides: 19
Download presentation
Project 1 Help Section Yu-Chi Lai Mohamed Eldawy 1/29/2022 © University of Wisconsin, CS

Project 1 Help Section Yu-Chi Lai Mohamed Eldawy 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Topics • • Color Dithering Warping Impressionist Questions 1/29/2022 © University of Wisconsin, CS

Topics • • Color Dithering Warping Impressionist Questions 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Transformation from One Image to Another 1/29/2022 © University of Wisconsin, CS 559 Fall

Transformation from One Image to Another 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Dithering with Floyd-Steinberg • Procedures for black and white – Turn color into grayscale:

Dithering with Floyd-Steinberg • Procedures for black and white – Turn color into grayscale: I=0. 299 R+0. 587 G+0. 114 B – Fill in the pixel with either black or white depends on the luminance of the current pixel – Diffuse the error (luminance difference between filled value and current value) to the adjacent unprocessed pixels – Zigzag until we reach the end can improve the result 1/29/2022 © University of Wisconsin, CS 559 Fall 2006 e 7/16 3/16 5/16 1/16

Dithering with Color • Difference between black-white and color dithering: – Choose the closest

Dithering with Color • Difference between black-white and color dithering: – Choose the closest color from the palette for the current pixel – Diffuse the error (color difference in r, g, b) to the adjacent unprocessed pixels 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Result (149, 91, 110)(176, 116, 137) (17, 11, 15) (63, 47, 69) (93, 75,

Result (149, 91, 110)(176, 116, 137) (17, 11, 15) (63, 47, 69) (93, 75, 112)(47, 62, 24) (76, 90, 55)(190, 212, 115) (160, 176, 87)(116, 120, 87) (245, 246, 225)(148, 146, 130) (200, 195, 180)(36, 32, 27) (87, 54, 45)(121, 72) 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Image Warping • A mapping between pixel locations – No color changes • Examples

Image Warping • A mapping between pixel locations – No color changes • Examples 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Some Examples 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Some Examples 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Challenges (1) • Direction of transform Forward for(int i = 0 ; i <

Challenges (1) • Direction of transform Forward for(int i = 0 ; i < wid ; i ++) for(int j = 0 ; j < hei ; j ++) { (i’, j’)= location of (i, j) in the destination result(i’, j’) = source(i, j) } OR for(int i = 0 ; i < wid ; i ++) for(int j = 0 ; j < hei ; j ++) { (i’, j’)= location where (i, j) comes from result(i, j) = source(i’, j’) } 1/29/2022 © University of Wisconsin, CS 559 Fall 2006 Backward

Challenges (2) for(int i = 0 ; i < wid ; i ++) for(int

Challenges (2) for(int i = 0 ; i < wid ; i ++) for(int j = 0 ; j < hei ; j ++) { (i’, j’)= location where (i, j) comes from result(i, j) = source(i’, j’) } Could be non-integer • Choosing a sampling method – Nearest neighbor – Bilinear – Gaussian 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Challenges (3) • This is not really a one to one mapping 1/29/2022 ©

Challenges (3) • This is not really a one to one mapping 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Coding Hints • A function that computes the mapping makes changing functions much easier

Coding Hints • A function that computes the mapping makes changing functions much easier – void transform(int x, int y, float& x 2, float& y 2) • A sampling function makes it easier to change sampling method – RGBTriple sample(int sampling. Method, float x, float y) • Don’t forget to handle the case of coordinates outside image • Can also be used in your resizing code 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Impressionist • Transform an image like a photo or a poster to some human

Impressionist • Transform an image like a photo or a poster to some human artistic styles. • From observation of human drawings, we must determine – – – Do it manually or automatically Where to draw What color should we use What size and shape of pens should we use What order should we place our draws What direction should we draw 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Impressionist (Automatic) • Easiest way to think about it is block by block –

Impressionist (Automatic) • Easiest way to think about it is block by block – Too mechanic 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Detailed (1) • To make it look nature, we can do – – –

Detailed (1) • To make it look nature, we can do – – – Choose the drawing points randomly Random choose the size of the pen and size of the strokes Perturbation of the choosing color. Orientation of the strokes Choose a special shape for the pen used such as square, circle, eclipse, or others. – Choose how to solve overlap problem – Make sure that the entire pictures has been covered 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Detailed (2) • Solve the overlap problem – Blending like watercolor drawing – Overwrite

Detailed (2) • Solve the overlap problem – Blending like watercolor drawing – Overwrite like oil painting 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Code Hint • For reusing your code, you can have a function to place

Code Hint • For reusing your code, you can have a function to place a draw on a position with your own designed shape, size and so on. • For example, I used this function void Place. Draw(Brush. Shape, Position, Size, Flag. For Blending. Method) • • 1/29/2022 Brush. Shape: an array to indicate the brush property e. g. circle, square Position: two float numbers to indicate where to place the draw Size: a float number, the size of the draw Flag. For. Blending. Method: integer to indicate overlap, blending, or other method © University of Wisconsin, CS 559 Fall 2006

Advance: Layer Drawing • When observing how human draw. – – Put a background

Advance: Layer Drawing • When observing how human draw. – – Put a background color on. Draw big regions Draw small regions in each big region. Draw the detail on each small region. • Pyramid Method – Decompose a picture into image pyramid (When implementing it, we use different size of filtering kernel – Place draws according to the information in each layer with different size of brush. 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Questions about Project 1 ? 1/29/2022 © University of Wisconsin, CS 559 Fall 2006

Questions about Project 1 ? 1/29/2022 © University of Wisconsin, CS 559 Fall 2006