Question: This is a big code, but does anyone know how to create a genetic algorithm in Mariah to breed a target image beginning from random

This is a big code, but does anyone know how to create a genetic algorithm in Mariah to breed a target image beginning from random pixels? 1)Initialize population members with random DNA
2) Calculate fitness of each member in population
3) Build mating pool based on fitness of each member
4) Select two parents from mating pool and breed child
5) Apply some random mutation to DNA of child
6) Repeat steps 4 and 5 until new population (new generation) has been bred
7) Repeat steps 2 through 6 for each new population until goal is reached
 This is a big code, but does anyone know how to

9 of 13 Painting the Mona Lisa We will now be converting our above methodology into a generative algorithm that can breed pictures. Provided on Moodle are several small pictures to test your algorithm out on, including various sizes of the Mona Lisa. It is highly recommended that you start this section with black and white images only (hint: your Luminance function from Assignment 7 might come of handy here!), it will save you lots of time in testing. Task 2.1: Convert your code so it processes images instead of strings. You will want to increase your population size to accommodate for the much larger genetic diversity you will need (note: try to limitthis to the total size of your image to avoid overfitting). You may also want to find a new exponential factor that works for you. Instead of printing our best phrase to the Command Window, we will now only print the generation number, the current maximum fitness, and the current average fitness of the population. Then, as seen on the first page, we will want to plot a sample of 9 maximum fitness members from evenly spaced generations (first subplot being Generation 1, last subplot being the final generation) Your function should save the absolute maximum fitness organism seen during all generations to an image file. You should still save maximum fitness, average fitness, and genetic diversity for each generation to a text file. Task 2.2: Improving the fitness function Because we are now dealing with images, we won't necessarily want to have our fitness be calculated by exact matches of DNA. Instead, if a pixel's colour is 'close enough(say+-10 on a scale of 0->255), we will count it as 'fit. Add a new variable tolerance in your calculateFitness function to achieve this. Because we are now dealing with images, there are new ways to analyze the fitness other than simply checking if the pixel is a match or not. We will add two new methods to evaluate fitness: by checking the average values around the pixels, and checking the rate of change between pixels (how quickly the color changes). For the first method, we will want to create a no loops version (for speed) of your meanFilter function from Assignment 7 (hint: it does not matter if you chop off a row/column or two in the output image to avoid dealing with the edge cases). We wil then compare the meanFilter version of each image to each other, with a similar tolerance as before

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!