I have mostly been working on my mutation and crossover functions this week. My mutation function originally used a bitmap for the mosaic but I changed
it so that it now uses the 2d array of Tiles. Right now I have 10 individuals(mosaics) in each population and I plan on selecting 4 mosaics, mutating 3,
and performing crossover on 3. I will likely increase the number of individuals but this ratio will likely remain similar. At the beginning of the week
I had a variable numToMutate in my mutation function and this would tell it to mutate 3 mosaics, but I changed it so that Mutation() only mutates 1 mosaic
and I use Mutation() on 3 mosaics within my event handler for the mutation button click. The mutation function calculates the number of tiles to change
and replaces random tiles with a new index. For crossover, a child is created using the top half of one mosaic and the bottom half of another mosaic.
The next thing I have to think about is how to add the mutated and crossover mosaics from the current population to the next generation.
This week I have made a change to my population's structure. Instead of each individual being a list of 100 mosaics,
each one is only going to be 1 mosaic and there can be many individuals instead of 10. I am planning on either having
50 or 100. The image below is the new structure. Also, I am working on making each tile only be an index from the list of tile options rather than a bitmap visualization and an average color.
These changes will make memory usage more efficient.
I have been thinking about how I want to store my data and making sure I am visualizing data structures correctly. To do this, I have been making drawings of my data structures. I currently have each population as
a list of bitmaps, with each mosaic being a bitmap. Dr. Pankratz suggested that I store the mosaics as 2D arrays instead, and I think that is a good idea,
so I am working on the implementation of the 2D arrays. I made public classes for Tile and Individual so that it is easier to work with populations. I am also working on making a color palette for the tiles that has the exact colors found in the target image.
Below is a drawing I made to explain what the populations look like. Each population has a list of 10 individuals, and each individual will have
100 mosaics within it.
This week I have created the random generation of solid-colored tiles and worked on adding in mutation. This random
generation will be the first generation that will be used by the genetic algorithm. My next steps are to continue
working on the genetic algorithm, implementing selection and crossover.
Unfortunately, I was sick for half of this week and therefore did not get as much done as I was hoping. I was able to
initialize the solid colored tiles into a List. Right now, I have 10 hard-coded tiles in the List. I encountered a
problem in my fitness function where the List of tiles was showing up as null. Thankfully, Dr. McVey helped me realize
it was an issue with redeclaration. Right now, I am working on creating and displaying the random generation of the
solid colored tiles. After that, I will implement mutation.
This past week, I was able to meet with Dr. McVey and we confirmed that my function that gets the average color from a tile works
correctly. We also discussed next steps for my project and I am currently working on those next steps. We had discussed figuring out
a data structure to store the tiles. After looking into the differences between ArrayLists and Lists in C#, it seems like Lists are
the better option for my project. It is type-safe which I think will be helpful. I have updated my fitness function to check the whole
user-uploaded image rather than just one tile.
I am currently working on properly storing tiles and
I want to be able to display the tiles that are going to be used to create the mosaic. For now, these will be solid colored tiles. After that,
the first part of the genetic algorithm that I will implement is mutation.
This week I have been working mostly on the fitness function and testing the program. I implemented Euclidean Distance within
the fitness function. This is a more accurate representation of color distance. I also added a visual of a randomly generated color
beneath the user-uploaded image that is compared to the top left tile of the image. Next to the image is a copy of the image that shows
the grid to help visualize the tiles. My next step is to begin the implementation of the genetic algorithm. This will include selection,
crossover, and mutation.
This week I worked on the function for the user to upload an image. I made it so that the user clicks on the picture box in order
to upload. I also wrote a very basic fitness function so that I can start testing how the tiles work. Right now my fitness function
compares a random tile color to a tile in the top left corner of the user-uploaded image. It takes the average of red, average of green, and
average of blue in the tile of the original image and subtracts the RGB values of the random tile from those values. The fitness score is
the average of these distances. My next steps are to display more information to the screen for testing purposes. I want to show the tile
that is being compared to the tile in the uploaded image as well as display the grid next to the image. I also plan on improving the fitness
function by using absolute values and squaring the values.
This week we got to present our initial ideas for our projects to the class to get some feedback.
Overall, I plan on keeping a lot of the ideas in my original UI design while changing a few things.
One thing that was brought up was to think about how I am going to display the generation of the mosaic
because so many are going to be generated that I cannot show every single one. I think it is a good idea to
show a generation every certain amount of generations. For example, I could display every 50th generation.
This week I also got a much better understanding of the components of the genetic algorithm. The biggest idea
I have been thinking about is the fitness function which will summarize how closely a particular solution(mosaic)
matches the original picture uploaded by the user. Dr. McVey gave me a couple ideas for the fitness function. One way is
to find the RGB value of each tile and calculate the difference between each tile and its corresponding section on the original
image. Then, I would have to find a summation of all the differences to get an overall fitness score. Another way is to
get the RGB value of about 5 points in each tile, 1 on each edge and 1 in the middle. This could help with being able to
correctly match up the edges among the tiles.
Over the past two weeks, I have been in the planning phase of my project. I have created a UI design
that will help me think about what I want the final design to look like although I will probably change
it a little based on what I want the user to be able to control. I originally wanted to write my project in
JavaScript because I am familiar with it. I started
writing some of the code and was able to allow the user to upload an image of their choice. However,
after considering how computationally intensive this project is going to be, I have decided to write it in
C#. So, my next step is to learn some C# by looking over some labs Dr. McVey has provided. Below is my current
UI design.