Skip to content

Commit

Permalink
Fixed oversampling issue
Browse files Browse the repository at this point in the history
Images are generated and evaluated at 200x200 resolution, regardless of
input image size. This makes very large images simple to use.
  • Loading branch information
StevenGann committed Oct 16, 2015
1 parent 7216aef commit 3874156
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions GenePainter/GeneticBitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ private int FitnessFunction(Genome genome)

generatedBitmap = GenomeToBitmap(genome);

int sampleSize = (int)((float)((int)targetBitmap.Width * (int)targetBitmap.Height) * ((float)accuracy/100.0f));
int sampleSize = 0;// (int)((float)((int)targetBitmap.Width * (int)targetBitmap.Height) * ((float)accuracy / 100.0f));

Bitmap tb;
Bitmap gb;
Expand All @@ -261,6 +261,7 @@ private int FitnessFunction(Genome genome)
//gb = new Bitmap(generatedBitmap);
tb = ResizeImage(targetBitmap, 200, 200);
gb = ResizeImage(generatedBitmap, 200, 200);
sampleSize = (int)((float)(tb.Width * tb.Height) * ((float)accuracy / 100.0f));

ta_t = new Bitmap(tb);
ta_g = new Bitmap(gb);
Expand Down Expand Up @@ -437,8 +438,8 @@ public Bitmap GenomeToBitmap(Genome genome)

lock (this)
{
tw = targetBitmap.Width;
th = targetBitmap.Height;
tw = 200; // = targetBitmap.Width;
th = 200; // = targetBitmap.Height;
}

Bitmap output = new Bitmap(tw, th);
Expand Down Expand Up @@ -581,10 +582,10 @@ public static Bitmap ResizeImage(Bitmap image, int width, int height)
using (var graphics = Graphics.FromImage(destImage))
{
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighSpeed;
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
graphics.SmoothingMode = SmoothingMode.HighSpeed;
graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;

using (var wrapMode = new ImageAttributes())
{
Expand Down
Binary file modified GenePainter/bin/Debug/GenePainter.exe
Binary file not shown.
Binary file modified GenePainter/bin/Debug/GenePainter.pdb
Binary file not shown.
Binary file modified GenePainter/obj/Debug/GenePainter.exe
Binary file not shown.
Binary file modified GenePainter/obj/Debug/GenePainter.pdb
Binary file not shown.

0 comments on commit 3874156

Please sign in to comment.