170 likes | 361 Views
Approximating image by relaxation. Approximating Images by Relaxation. General idea. candidate fitness function Look at the candidate and assigns it a numerical score High score to a better candidate than to a less one If instead a better candidate gets a lower score -> penalty function.
E N D
General idea • candidate • fitness function • Look at the candidate and assigns it a numerical score • High score to a better candidate than to a less one • If instead a better candidate gets a lower score -> penalty function
The process best candidate <- initial candidate best score <- score(best candidate) while (!enough) { new candidate <- purburbing(best candidate) new score <- score(new candidate) if (best score > new score) { best score <- new score best candidate <- new candidate } }
Basic loop of the algorithm Candidate PertubStep(double *bestScore, Candidate bestC, Procs procs) { Candidate newC = procs->perturb(bestC); double newScore = prcs->score(newC); if (newScore < *bestScore) { procs->save(newC); bestC = newC; *bestScore = newScore; } return(bestC); }
Functions • Cadidate init() • Called before the optimizer runs, this sets up any required storage, and generates and returns the first candidate • Candidate perturn(Candidate c) • Perturb the input and return the perturbed version • double score(Candidate c) • Compute the penalty score for this candidate • void save(Candidate c) • Save the image specified by this candidate
Scoring • Basic error measure • Importance weighted error measure • Two more measure • Overlap penalty • Gap penalty
Scoring • Input • rImage: the reference image • cImage: the candidate image • The error at each pixel • Ep = Δr2 + Δg2 + Δb2 • The total error is the result of summing up this measure
Scoring • Optional importance measure • iImage: importance image • Hand-painted or edge detected image • s: overall scale factor • I: the value of iImage at a specific pixel [0,1] • Importance-weighted error • Ei = s*I*Ep
Scoring • Overlap penalty • Count how many times a given pixel is written to over the course of rendering the image • c: counter • Po: overlap penalty value • Constant for the whole image • Measure: (c -1)*Po
Scoring • Gap penalty • If a given pixel has a count value c == 0 • Then add the score the value of a gap penalty value Pg • Constant for the whole image • The idea • To try to get all the pixels covered by at least one object, so that most of the background is covered
Scoring • Etotal = Σ Ei • Ei = s*I*Ep + (c -1)*Po + (c==0) ? Pg : 0
Perturbing • Swap the geometry • Picks a piece and changes it
Perturbing • ξ: random number, [0, 1] • t: probability of swapping, (0.05 ~ 0.1) • if (ξ < t) swaps a random pair of objects & returns else picks a pieces & changes it • Swapping • None of the shape change, but their order is altered
Perturbing • Shape change • Use permutation array • P: an array of integers that has as many entries as there are pieces of geometry • Initialize Pi = I • Scramble order of P • Modification of shape • As the simulation continues, the changes get smaller as pieces jostle into their best settings
Examples Initial image 9970th image
Examples Initial image 9917th image