Sisteme de programe pentru timp real Universitatea “Politehnica” din Bucuresti 2005-2006 Adina Magda Florea

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Indexing DNA Sequences Using q-Grams
© Fluent Inc. 4/16/ Introductory GAMBIT Notes GAMBIT v2.0 Jan 2002 Fluent User Services Center Edge and Face Meshing.
Michael Alves, Patrick Dugan, Robert Daniels, Carlos Vicuna
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
November 12, 2013Computer Vision Lecture 12: Texture 1Signature Another popular method of representing shape is called the signature. In order to compute.
Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
Grey Level Enhancement Contrast stretching Linear mapping Non-linear mapping Efficient implementation of mapping algorithms Design of classes to support.
Review for Test 3.
Algorithms + L. Grewe.
CS 551 / CS 645 Antialiasing. What is a pixel? A pixel is not… –A box –A disk –A teeny tiny little light A pixel is a point –It has no dimension –It occupies.
Image Segmentation Region growing & Contour following Hyeun-gu Choi Advisor: Dr. Harvey Rhody Center for Imaging Science.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
IK: Choose these angles!
Texture Mapping from Watt, Ch. 8 Jonathan Han. Topics Discussed Texture Map to Models Bump Maps, Light Maps Environment (Reflection) Mapping 3D Textures.
Review Best-first search uses an evaluation function f(n) to select the next node for expansion. Greedy best-first search uses f(n) = h(n). Greedy best.
Twelve painting with procedures. Overview Making shaded images with procedures Making a more elegant language Making textures with noise functions.
Lec 5 Feb 10 Goals: analysis of algorithms (continued) O notation summation formulas maximum subsequence sum problem (Chapter 2) three algorithms image.
Eighteen painting with procedures. Review [bitmap-from-procedure procedure width height] Returns a bitmap width pixels by height pixels Obtains colors.
Multiple Integrals 12. Surface Area Surface Area In this section we apply double integrals to the problem of computing the area of a surface.
10/5/04© University of Wisconsin, CS559 Fall 2004 Last Time Compositing Painterly Rendering Intro to 3D Graphics Homework 3 due Oct 12 in class.
Image processing Lecture 4.
Genetic Programming.
Chapter 1 – Functions and Their Graphs
Curve Modeling Bézier Curves
1 Computer Graphics Week13 –Shading Models. Shading Models Flat Shading Model: In this technique, each surface is assumed to have one normal vector (usually.
Chapter 10: Image Segmentation
©Brooks/Cole, 2003 Chapter 2 Data Representation.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
COMP 175: Computer Graphics March 24, 2015
 We noticed in Section 2.3 that the limit of a function as x approaches a can often be found simply by calculating the value of the function at a.  Functions.
Shorter of two objects and changing color V2 Functions, events and setting the color in sequence and randomly This is a modification of the Changing Color.
(Spline, Bezier, B-Spline)
COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 1 Shading (Shading) & Smooth Shading Graphics.
We noticed in Section 2.3 that the limit of a function as x approaches a can often be found simply by calculating the value of the function at a.  Functions.
Zorica Stanimirović Faculty of Mathematics, University of Belgrade
16 VECTOR CALCULUS.
Digital Media Dr. Jim Rowan ITEC Vector Graphics Elegant way to construct digital images that –have a compact representation –are scalable –are.
Computer Algorithms Submitted by: Rishi Jethwa Suvarna Angal.
Digital Image Processing CCS331 Relationships of Pixel 1.
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
Geometric Objects and Transformation
Digital Media Dr. Jim Rowan ITEC So far… We have compared bitmapped graphics and vector graphics We have discussed bitmapped images, some file formats.
CS559: Computer Graphics Lecture 8: Warping, Morphing, 3D Transformation Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
1 8. One Function of Two Random Variables Given two random variables X and Y and a function g(x,y), we form a new random variable Z as Given the joint.
Synthesizing Natural Textures Michael Ashikhmin University of Utah.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.
Flexible Automatic Motion Blending with Registration Curves
Digital Media Dr. Jim Rowan ITEC Vector Graphics Elegant way to construct digital images that –have a compact representation –are scalable –are.
Introduction to JPEG m Akram Ben Ahmed
One Function of Two Random Variables
Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan.
Graphics Lecture 2: Slide 1 Lecture 2 Transformations for animation.
Vectors and Scalars and Their Physical Significance.
MOHR'S CIRCLE The formulas developed in the preceding article may be used for any case of plane stress. A visual interpretation of them, devised by the.
Instructor: Mircea Nicolescu Lecture 5 CS 485 / 685 Computer Vision.
Genetic Programming Using Simulated Natural Selection to Automatically Write Programs.
Genetics in EACirc DESCRIPTION OF THE COMPONENTS BASED ON EVOLUTION.
Processing Images and Video for An Impressionist Effect Automatic production of “painterly” animations from video clips. Extending existing algorithms.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Chapter 14 Genetic Algorithms.
Genetic Algorithms.
Dr. Jim Rowan ITEC 2110 Wednesday, September 12
Digital Media Dr. Jim Rowan ITEC 2110.
Computer Animation Texture Mapping.
Motion Models (cont) 2/16/2019.
Presentation transcript:

Sisteme de programe pentru timp real Universitatea “Politehnica” din Bucuresti Adina Magda Florea

Curs Nr. 9 Genetic Algorithms applications GAIA 2

1 Generating new images using Genetic Algorithms The Gaia program has been developed as a tool to generate new kind of images. Based on the paper Artificial Evolution for Computer Graphics from Karl Sims (Computer Graphics, Volume 25, Number 4, July 1991), it uses the ideas of genetic algorithms and evolution to assist the user in the creation of new images. Every image is generated evaluating a mathematic formula in the real domain. The problem is to find formulas which, when evaluated, give us interesting images. We use genetic algorithms to find this formulas. 3

Generating new images using Genetic Algorithms Starting from a random and simply formula, the program generates multiple variations of the current image modifying slightly the formula. The new formulas are evaluated and the results presented to the user, which will choose and select the most interesting one based on his artistic criterion. The selected formula becomes the new generator and the process is repeated again, closing this way the cycle. The concept of evolution is used to find new formulas from the current ones: the new formulas become not so simply, and the associated images quite good looking. 4

Generating new images using Genetic Algorithms 5 (lerp #( ) (- (triwave (RAD)) 0.590) (PHY)) (color_grad "earth" (gradient (log (+ (&& (lerp (PHY) #( ) (RAD)) (RAD)) #( ))))) (color_noise (mod (warped_color_noise (X) #( )) (Y)) (color_noise (X) (invert (Y))))

Generating new images using Genetic Algorithms 6 (lerp (* (vector (warped_bw_noise (RAD) #( ) (Y) (RAD)) (RAD)) (X)) (RAD) (bw_noise (PHY) (log 0.529))) (triwave (- (^^ (&& (RAD) (PHY)) (PHY)) #( ))) (mynoise (triwave (|| (RAD) (PHY))) (RAD))

Generating new images using Genetic Algorithms 7 (lerp (* (X) (X)) (/ (/ #( ) (RAD)) (RAD)) (bw_noise (RAD) (RAD))) (triwave (lerp (min (lerp (PHY) (lerp (PHY) (RAD)) #( )) (PHY)) (IRAD) (RAD))) (color_noise (cos (+ (bw_noise (mod (X) (Y)) #( )) (Y))) 0.296)

Generating image transitions using Genetic Algorithms The program can also generate smooth transitions between any images generated in the program.smooth transitions The user selects the source and the target images, and the program finds the frames which will transform the source image in the target image. If the formulas used to compute the images have nothing in common, the transition will be a pure melt If the formulas have some similarities, we obtain an interesting transition of forms. 8

Generating image transitions using Genetic Algorithms 9 Source: (triwave (abs (RAD))) Target: (triwave (abs (X)))

Generating image transitions using Genetic Algorithms 10 Source: (triwave (abs (X))) Target: (triwave (&& (PHY) (PHY)))

Generating image transitions using Genetic Algorithms 11 Source: (/ (& (Y) (X)) (RAD)) Target: (/ (& (Y) (RAD)) (RAD))

2 Genotype Gaia codes every image generated with a formula and a domain. Both elements are the genotype of the solutions. The formulas are mathematical expressions built from a set of operators and constants.a set of operators and constant The expression is stored in Lisp format, and tells Gaia how the image should be evaluated. The domain tells Gaia where the formula should be evaluated. The domain is simply a region of the real plane specified as the limits in both directions. The default domain used is [-1..1] x [-1..1]. 12

2 Genotype The formulas can be as long as desired, they have no fixed length. The formulas are frequently shown in tree representation, showing how the expression is evaluated. Every node in the expression has one branch for each argument it needs, where it hangs more nodes. The operators with no arguments are the leafs of the tree, while the root node is that with no parent: the last one begin evaluated. Lisp Expression Domain (+ (+ (X) (Y)) (Y)) [0..1] x [0..1] (gradient (invert (- (0.5) (RAD)))) [-1..1] x [-1..1] (abs (lerp (mynoise (/ (triwave (mod (PHY) )) (RAD)) (min (RAD) )) (Y) (X)))[-1..1] x [-1..1] 13

3 Formulas & operators Formulas are sequences of operators and functions arranged in tree form. There are five classes of operators: 1.Domain operators: Those like X,Y,RAD,PHY which depends on the domain where the formula is being evaluated.X,YRADPHY X, Y Returns an image which is directly the values of the domain in the X-axis or Y-axis directions. So the resulting images are horizontal and vertical ramps of luminance. These images where obtained with the domain [0..1] x [0..1] 14

3 Formulas & operators RAD The resulting image depends directly on the domain where it is evaluated. The luminance of each pixel in the image is directly the distance from the coordinates of the pixel in the domain to the origin, typically at the center. IRAD Similar to the operador RAD, the luminance of each pixel is the distance measured to the nearest odd integer in the domain. The black corners represents the four integer coords (-1,-1) (- 1,1) (1,1) (1,-1) of the domain where the image was rendered. 15

3 Formulas & operators PHY The luminance of the resulting image represents the angular coordinate of the pixel, with the zero heading down.There where the value is greater than 1 a white pixel is used. 16

3 Formulas & operators 2. One argument functions: From a single image, returns a new image after applying some function to the pixels values of the argument. Some examples of functions are compute his cos, sin, normalize, gradient, abs, round, triwave,...triwave TRIWAVE This operator is important because it is bounded in the interval 0..1 for all the source values. This means that we can feed this operator with any image with any pixel values, that the resulting image will be limited between 0 and 1. 17

3 Formulas & operators 3. Simply operators: Combines two images to return the result of the operator. The combination operator can be as easy as add the images, substract, multitply, or combine logically at pixel level. 4. Complex operators: Need more than two images as arguments and returns a more complex combination of them. They usually use some of them as parameters of the combination. Examples: LERP, noise functions, color grad,... 5.Misc operators: Here are included the operators which uses external images imported from other programs or those which uses the templates of the program 18

3 Formulas & operators LERP It takes three images as arguments: A,B,C. and computes the resulting image as A+(B-A)*Triwave(C). So it makes a linear interpolation from A to B, using C as weight of the interpolation. The operator Triwave is included to limit C in the interval

4 Mutation Evolution is achived by two methods: Mutation and Combination.Mutation Combination Mutations A mutation can be though as a modification of the genotype. From a starting genotype we can generate similar images performing changes in the genotype and evaluating the new formulas. If we are using a long formula to obtain an image, and make some little changes in the formula, the final image will be in general quite similar but different. Mutations are normally applied on a single node, and affects this node and maybe nodes in lower levels. This node is chosen randomly in the tree. 20

4 Mutation New Node: The selected node is substituted by a new simply random node. This type of mutation can achieve important changes when the original tree is big, and the node is near the root of the tree. Adjust Node: The node is modified by another one with the same number of parameters. The tree maintains the same structure, but instead of computing the cos (maybe) we will compute the sin, or maybe we will change a constant with value 0.7 by a new one with value 0.5. This type of mutation makes light changes. Node as arg: The selected node becomes the argument of a new random node which is placed in his previous location in the tree, and the old node hanging from it. If the new node needs more arguments they are generated randomly. 21

4 Mutation Arg as node: The inverse operation. One of the arguments of the node substitutes the node itself. The new tree is simpler than the original. If the original node got more arguments, they are discarded. Node as uncle: The node is substituted by a copy of a node in upper levels of the tree. Reorder arguments: This operator changes the order of the arguments of the selected node (assuming it has more than two). It can be very different to compute X / RAD or RAD / X.X RAD The more mutations we apply, the more differences we get between parent and child images. The default number of mutations applied is one, but when formulas become bigger, it is preferable to use two or three. In Gaia, there is only one parent. Children are obtained by performing different types of mutations in different nodes of the same parent. 22

4 Mutation examples Parent expression: (triwave (mod (triwave (PHY)) (RAD))) Domain: [-1..1] x [-1..1] 23

4 Mutation examples 1.(triwave (mod (lerp (PHY) (Y) (Y)) (RAD))) 2.(mod (triwave (PHY)) (RAD)) 3.(triwave (mod (^^ (triwave (PHY)) (X)) (RAD))) 4.(triwave (mod (PHY) (RAD))) 5.(triwave (lerp (mod (triwave (PHY)) (RAD)) (Y) (RAD))) 6.(triwave (mod (max (triwave (PHY)) (RAD)) (RAD))) 7.(triwave (sin (triwave (PHY)))) 8.(triwave (mod (+ (triwave (PHY)) (RAD)) (RAD))) 9.(triwave (mod (triwave (PHY)) (warped_color_noise (RAD) #( ) #( ) (X)))) 10.(mod (mod (triwave (PHY)) (RAD)) (PHY)) 11.(triwave (mod (RAD) (triwave (PHY)))) 12.(triwave (rotate (mod (triwave (PHY)) (RAD)) (RAD))) 13.(triwave (mod (gradient (triwave (PHY))) (RAD))) 14.(invert (triwave (mod (triwave (PHY)) (RAD)))) 15.(triwave (* (mod (triwave (PHY)) (RAD)) (X))) 16.(triwave (mod (abs (PHY)) (RAD))) 24

4 Mutation examples 25 (triwave (mod (triwave (PHY)) (RAD))) (triwave (mod (lerp (PHY) (Y) (Y)) (RAD)))

5 Combination With this type of evolution we want to find a method to generate images that share characteristics of two previously generated images. To accomplish this we will rely on the fact that the relation between formulas and images is basically associated to the sequences of operators used in the genotypes, rather than the individual operators used. So we will try to maintain sequences of nodes of the parent and mother in the new genotypes. 26

5 Combination The steps to generate new offspring by combining two genotypes are: Select one random node in the parent tree, and one random node in the mother tree. Break the trees by this points. Parent is divided in P1 and P2, and mother in M1 and M2. Interchange the parts of the genders. Create two new expressions C1=P1+M2 and C2=M1+P2 Repeat the process choosing other nodes in the parent and mother trees. 27

5 Combination 28 Parent Mother Child 1Child 2

5 Combination examples Parent expression: (lerp (* (vector (warped_bw_noise (RAD) #( ) (Y) (RAD)) (RAD)) (X)) (RAD) (bw_noise (PHY) (log 0.529))) Domain: [-1..1] x [-1..1] Mother expression: (lerp (triwave (PHY)) (* (lerp #( ) (- (triwave (RAD)) 0.590) (PHY)) (triwave (mod (triwave (PHY)) (RAD)))) (RAD)) Domain: [-1..1] x [-1..1] 29

5 Combination examples 30

5 Combination examples (lerp (triwave (RAD)) (* (lerp #( ) (- (triwave (RAD)) 0.590) (PHY)) (triwave (mod (triwave (PHY)) (RAD)))) (RAD)) (lerp (triwave (PHY)) (* (lerp #( ) (bw_noise (PHY) (log 0.529)) (PHY)) (triwave (mod (triwave (PHY)) (RAD)))) (RAD)) (lerp (triwave (PHY)) (* (lerp #( ) (- (triwave (RAD)) 0.590) (PHY)) (triwave (mod #( ) (RAD)))) (RAD)) (* (lerp #( ) (- (triwave (RAD)) 0.590) (PHY)) (triwave (mod (triwave (PHY)) (RAD)))) (lerp (triwave (PHY)) (* (lerp #( ) (- (triwave (RAD)) 0.590) (X)) (triwave (mod (triwave (PHY)) (RAD)))) (RAD)) (lerp (* (vector (warped_bw_noise (RAD) #( ) (Y) (RAD)) (RAD)) (- (triwave (RAD)) 0.590)) (RAD) (bw_noise (PHY) (log 0.529))) (lerp (triwave (PHY)) (* (lerp #( ) (- (triwave (RAD)) 0.590) (PHY)) (triwave (mod (triwave (PHY)) (RAD)))) (bw_noise (PHY) (log 0.529))) (lerp (* (vector (warped_bw_noise (RAD) #( ) (Y) (lerp #( ) (- (triwave (RAD)) 0.590) (PHY))) (RAD)) (X)) (RAD) (bw_noise (PHY) (log 0.529))) 31

5 Combination examples (lerp (triwave (PHY)) (* (lerp #( ) (- (triwave (RAD)) 0.590) (PHY)) (triwave (mod (triwave (PHY)) (RAD)))) (RAD)) (lerp (triwave (PHY)) (* (lerp #( ) (RAD) (PHY)) (triwave (mod (triwave (PHY)) (RAD)))) (RAD)) (lerp (* (vector (PHY) (warped_bw_noise (RAD) #( ) (Y) (RAD)) (RAD)) (X)) (RAD) (bw_noise (PHY) (log 0.529))) (lerp (* (vector (warped_bw_noise (RAD) #( ) (Y) (RAD)) (RAD)) (X)) (RAD) (bw_noise (PHY) (log (RAD)))) (lerp (triwave (PHY)) (log 0.529) (RAD)) (lerp (* (vector (warped_bw_noise (RAD) #( ) (Y) (RAD)) (RAD)) (X)) (* (lerp #( ) (- (triwave (RAD)) 0.590) (PHY)) (triwave (mod (triwave (PHY)) (RAD)))) (RAD)) (lerp (triwave (PHY)) (* (lerp #( ) (- (triwave (RAD)) 0.590) (PHY)) (triwave (bw_noise (PHY) (log 0.529)))) (RAD)) (lerp (triwave #( )) (* (lerp #( ) (- (triwave (RAD)) 0.590) (PHY)) (triwave (mod (triwave (PHY)) (RAD)))) (RAD)) 32

6 Image transitions The software is able to make smooth transitions between images This means that the user selects one image as the source, and another as the target, and Gaia will make automatically a smooth transition between both images. Depending on the semblance of both source and target, the transition will be a simply melt if the genotypes have nothing in common, but it can be an interesting transition if there are some similarities in the genotypes. We say that two genotypes are similar if they share the upper nodes of the genotypes (the nodes near the root node). The more nodes they share, the more similar they are. If both expressions have different root nodes, the expressions have nothing in common. 33

6 Image transitions To obtain the animation, Gaia generates a new genotype parametrized in time. This new genotype has the common nodes of source and target images, and interpolates in time the nodes which are different. This means that when the parameter t = 0, the genotype is equivalent to the source genotype, while when t = 1, the genotype match the target. Between, the genotype is a proportional mix of both genotypes. Important here: making a simply melt of the different nodes, but when apply the operators, the melt is visualized as a transformation of forms in the image, and not just as an interpolation of colors. 34

6 Image transitions Source genotypeTarget genotypeNew genotype The blue nodes are common to both source and target genotypes, while the red and green nodes are different. The gray nodes are inserted to interpolate in time the different nodes. The program inserts this special join node every time the nodes of source and target differs. 35

6 Image transitions Source genotypeTarget genotypeNew genotype Source genotype: (+ (X) (* (RAD) (Y))) X + RAD*Y Target genotype: (+ (X) (* (RAD) (Cos (* (2) (PHY))))) X + RAD*(Cos(2*PHY)) New genotype: (+ (X) (* (RAD) (+ (* (1-t) (Y)) (* (t) (Cos (* (2) (PHY))))))) X + RAD* ((1-t)*(Y) + (t)*(Cos(2*PHY))) 36

6 Image transitions Another type of animation is accomplished when the domains are different. In this case, the intermediate domains is also a proportional mix of the source and target domains, finding an easy way to get zooms (magnification and reduction) and displacements of the images. 37

38 Source: (triwave (abs (X))) Target: (triwave (&& (PHY) (PHY))) 6 Image transitions

39 Source: (lerp (/ (gradient (& (PHY) (RAD))) (RAD)) (Y) #( )) Target: (lerp (Y) #( ) (/ (gradient (& (PHY) (RAD))) (RAD))) 6 Image transitions