• Content count

  • Joined

  • Last visited

Community Reputation

128 Neutral

About phyitbos

  • Rank
  1. Speedy Image Likeness Comparison

    Thanks to everyone (especially Spiro for the continued support!) your answers have been very helpful! I've learned some very important things here [img][/img]
  2. Speedy Image Likeness Comparison

    Wow, yes apparently GetPixel is incredibly slow. I don't understand the idea behind image locking, but I found this post that explains how to get access to the bitmaps byte array. [url=""][/url] That cut the algorithms time down to 11 ms using the Marshal'ing method. To subtract the RGB values from each other just (aR+aG+aB)-(bR+bG+bB)?
  3. Speedy Image Likeness Comparison

    I was going to move in to making it work for color images eventually, but I figured to start with greyscale cause it should be faster. Thanks for the tip about color images though. Kinda expected it to go faster myself, so I wouldn't be surprised if something's wrong. Here's my function for it (C#): [CODE]private double GetEuclideanDistance(Image img1, Image img2) { int dist = 0.0; try { Bitmap a = new Bitmap(img1); Bitmap b = new Bitmap(img2); if (a.Width != b.Width || a.Height != b.Height) { System.Windows.Forms.MessageBox.Show("Target comparable image does not have the same dimensions. Cannot get Euclidean Distance."); return 0; } int nRows = a.Height; int nCols = a.Width; for (int row = 0; row < nRows; row++) { for (int col = 0; col < nCols; col++) { int d = a.GetPixel(col, row).ToArgb() - b.GetPixel(col, row).ToArgb(); dist += (d * d); } } } catch (Exception ex) { IEvo.ReportException(ex, "GetEuclideanDistance"); } return Math.Sqrt(dist); }[/CODE] My timings show that it takes around 400ms to complete every time. Only about 15 ms for it to copy the images in to Bitmaps.
  4. Hello all, I am writing a program that uses a genetic algorithm to 'evolve' a randomly generated image in to a template image that I provide. Here is what it looks like: [img][/img] Every generation it creates (by default) 150 copies with random mutations (ellipse color/shape), and then compares them all to the template picture to see which is most similar, and that one moves on to the next generation. The current method I use to compare them is a pixel by pixel Euclidean Distance measurement. This takes about 8-9 seconds to evaluate the 150 children. Which might not seem like much, but to get a decently evolved image it can take at least 40,000 generations (about 4 days at given speed). This is too slow to test the results of different mutation rate / children / etc combinations. What faster methods of comparing the two images are there? Or what other ideas do you have to make this more efficient? My only thought so far is to reduce the dimensions of the images but that takes the fun out of creating a high quality replica ;)
  5. My first real language that I taught myself (other than web script languages) was C#. It's still my favorite for general purpose applications. C# isn't the best for cross-platform, but if you are mostly going to write Windows applications, C# and the .NET Framework offer you more. Finally, once you know C#, Java comes secondhand, they are *very* similar.
  6. Hi, I am learning about genetic algorithms and my goal is to make a replica (similar at any rate) to the one shown in this YouTube video: [media][/media] I need to be able to rate the "fitness" of my generated images. To do this, I need to compare them to a supplied picture, and was wondering what algorithm I should use to quantify the similarity (distance?) between the two images. I'm not familiar with algorithms in this category, so any insight would be very helpful! One that is simple to implement would be best, considering the goal of my project is the genetic algorithm and not comparing images, although a little learning never hurts [img][/img] Thanks in advance!
  7. I am trying to create a program that models simple artificial life similar to what the guy made in this video: [media][/media] So far my program has some critters that scurry around my screen looking for food but with no "brain". I've never messed with neural networks before but have been reading up on them in books and online for the past few days. This particular case seems a bit different from your basic neural network in some aspects though. It seems that his NN doesn't use any type of learning or error measuring, but rather it does this from the evolution of the creatures? I'm thinking that the weights are randomly initialized and that the creatures that are best fit / survive in general have their weights copied over to the next generation (with crossover and random mutation)? He says the brain consists of a directed graph where the edges are weights, and I'm guessing this is what he means?