示例#1
0
		public List<Match> Match(DistortedPalette palette, DeltaEMap scoreMap, FilteredMap filter, Picker picker)
		{
			var results = new ConcurrentBag<Match>();

			BeginTrack(nameof(Match), "Beginning brute force matching.");

			Parallel.ForEach(filter.Index, p =>
			{
				results.Add(DoMatch(p, palette, scoreMap, filter, picker));
			});

			EndTrack(nameof(Match), "Calculated {0:N0} matches", results.Count);

			return new List<Match>(results);
		}
示例#2
0
		private Match DoMatch(Point index, Palette palette, DeltaEMap scoreMap, FilteredMap filter, Picker picker)
		{
			// We'll choose our centerpoint so the first picker lines up with the found color
			var zeroPoint = new Point(index.X - picker.FirstCursor.X, index.Y - picker.FirstCursor.Y);

			var selectedColors = new List<SelectedColor>();

			foreach (var cursor in picker.Cursors)
			{
				var p = zeroPoint.TileOffset(cursor.X, cursor.Y, palette.Width, palette.Height);
				selectedColors.Add(new SelectedColor(p, Color.FromArgb(palette[p.Y, p.X]), scoreMap[p.Y, p.X], filter[p.Y, p.X]));
			}

			return new Match(selectedColors, zeroPoint);
		}
示例#3
0
        public static void Main()
        {
            var p = new RawPalette("test", 256, 256, RawPalette.LoadRaw(@"C:\Users\Scott\Documents\Mabinogi\212\color\cloth.raw"));
            p.ToImage().Save("test.png");

            p.Distortions.Add(new DistortionParameters(1, 1, 1, .5));
            p.Distortions.Add(new DistortionParameters(1, 2, 1, .3));
            p.Distortions.Add(new DistortionParameters(1, 1, 1, .2));
            p.Distortions.Add(new DistortionParameters(1, 2, 1, .03));

            var map = new DistortionMap(1,
                File.ReadAllBytes(@"C:\Users\Scott\Documents\Mabinogi\212\color\displace\displace_2.raw"));

            var dst = new DistortionEngine(new [] { map });

            var b = dst.Distort(p, 0, 256, 256);

            b.ToImage().Save("test_dist.png");

            var diff = new DifferenceEngine();

            var cm = diff.Calculate(new Rgb {R=255, G=255, B=255}.To<Lab>(), b.LabPalette);

            cm.ToImage().Save("test_map.png");

            var fm = cm.Filter(0);

            fm.ToImage().Save("test_filter.png");

            var picker = new Picker(new[] {new Point(0, 0), new Point(-11, -11), new Point(10, -11), new Point(-11, 10), new Point(10, 10) });

            var matches = new MatchingEngine().Match(b, cm, fm, picker);

            //foreach (var m in matches.OrderByDescending(m => m.NumberOfSuccess).ThenBy(m => m.Score))
                //Console.WriteLine(m);
        }