GetDrawingFitness() public static method

public static GetDrawingFitness ( DnaDrawing newDrawing, Color sourceColors ) : double
newDrawing GenArt.AST.DnaDrawing
sourceColors System.Drawing.Color
return double
Example #1
0
        private void WorkerThreadStart()
        {
            Initialize();

            while (isRunning)
            {
                //assign current work data to a tmp var, so that we use the same data through the entire itteration
                //even if data is changed by the main thread, nothing will break or go wrong.
                WorkerData tmpData = data;


                if (tmpData.hasNewParent)
                {
                    Tools.InitRandom(tmpData.randomSeed);
                    tmpData.hasNewParent = false;
                }


                DnaDrawing newDrawing = GetMutatedSeedSyncedDrawing();

                double newErrorLevel = FitnessCalculator.GetDrawingFitness(newDrawing, info.SourceImage,
                                                                           partitionY, partitionHeight);

                var result = new DnaPartitionResult
                {
                    Drawing    = newDrawing,
                    ErrorLevel = newErrorLevel,
                };


                tmpData.workerTail.Enqueue(result);
            }
        }
        public double GetNextErrorLevel()
        {
            var drawing = new DnaDrawing();

            drawing.SourceImage = sourceImage;
            drawing.Polygons    = new List <DnaPolygon>();
            int i = 0;

            foreach (LayeredWorker worker in workers)
            {
                i++;

                if (i == 1)
                {
                    continue;
                }

                DnaDrawing workerDrawing = worker.GetDrawing();
                drawing.Polygons.AddRange(workerDrawing.Clone().Polygons);
                //drawing = worker.GetDrawing();
            }

            currentDrawing = drawing;

            currentErrorLevel = FitnessCalculator.GetDrawingFitness(drawing, sourceImage);
            return(currentErrorLevel);
        }
Example #3
0
        public DefaultEvolutionJob(DnaDrawing drawing, JobInfo info)
        {
            this.info = info;

            if (drawing == null)
            {
                drawing = GetNewInitializedDrawing(info);
            }
            lock (drawing)
            {
                currentDrawing = drawing.Clone();
            }

            currentErrorLevel = FitnessCalculator.GetDrawingFitness(currentDrawing, info.SourceImage);
        }
Example #4
0
        public DnaDrawing GetDrawing()
        {
            DnaDrawing newDrawing = CurrentDrawing.Clone();

            newDrawing.Mutate(settings);

            double newErrorLevel = FitnessCalculator.GetDrawingFitness(newDrawing, newDrawing.SourceImage);

            if (newErrorLevel <= CurrentErrorLevel)
            {
                CurrentDrawing    = newDrawing;
                CurrentErrorLevel = newErrorLevel;
            }

            return(CurrentDrawing);
        }
Example #5
0
        public double GetNextErrorLevel()
        {
            Generations = 0;
            DnaDrawing newDrawing = currentDrawing.Clone();

            while (newDrawing.IsDirty == false)
            {
                newDrawing.Mutate(info);
                Generations++;
            }

            double newErrorLevel = FitnessCalculator.GetDrawingFitness(newDrawing, info.SourceImage);

            if (newErrorLevel <= currentErrorLevel)
            {
                currentDrawing    = newDrawing;
                currentErrorLevel = newErrorLevel;
            }

            return(newErrorLevel);
        }