public void MakeOption(ImageSides imageSides) { foreach (var keyValuePair in map) { switch (keyValuePair.Key) { case Side.Top: { top_map.AddRange(CalculateOptionForEachSide(keyValuePair.Value, imageSides)); break; } case Side.Bot: { bot_map.AddRange(CalculateOptionForEachSide(keyValuePair.Value, imageSides)); break; } case Side.Left: { left_map.AddRange(CalculateOptionForEachSide(keyValuePair.Value, imageSides)); break; } case Side.Right: { right_map.AddRange(CalculateOptionForEachSide(keyValuePair.Value, imageSides)); break; } } } }
public void analyze(List <string> lists) { //Create image objects from path var images = new List <ImageSides>(); foreach (var imagePath in lists) { var imageSide = new ImageSides(new Bitmap(imagePath, true)); images.Add(imageSide); } //create map of posible sides for each image with other ones foreach (var imageSideBase in images) { foreach (var imageSide in images) { if (imageSideBase != imageSide) { imageSideBase.MakeOption(imageSide); } } } //Create class to calculate others sides RezultImage rezultImage = new RezultImage(images); // /* * switch (side) * { * case Side.Top: * { * * break; * } * case Side.Bot: * { * break; * } * case Side.Left: * { * break; * } * case Side.Right: * { * break; * } * } */ //rezultImage.Connect(opt.Key, new ImageSides(opt.Value.img)); }
private List <Option> CalculateOptionForEachSide(Color[] value, ImageSides imageSidesExt) { var options = new List <Option>(); foreach (var pairExternal in imageSidesExt.map) { if (pairExternal.Value.Length == value.Length) { options.Add(new Option() { img = imageSidesExt, side = pairExternal.Key, similarity = CalculateSimularity(value, pairExternal.Value) }); } } return(options); }
public void AddImageToRezultList(ImageSides imgBase, ImageSides imgNew, Side pos) { //coordinats int x = 0, y = 0; //find location of base image foreach (var images1 in imageSidesRezultImage) { int loc = -1, iter = 0; foreach (var img in images1) { if (img != null && img.image == imgBase.image) { loc = iter; } iter++; } if (loc != -1) { x = loc; y = imageSidesRezultImage.FindIndex(i => i == images1); } } //position of new one to base switch (pos) { //to add new image under base one case Side.Top: //Bot to the Base one { try { var sms = imageSidesRezultImage[y + 1]; // try if we have enouth lists under our if (sms.Count > x) { imageSidesRezultImage[y + 1][x] = imgNew; } else { for (int i = imageSidesRezultImage[y + 1].Count; i <= x; i++) { imageSidesRezultImage[y + 1].Add(null); } imageSidesRezultImage[y + 1][x] = imgNew; } } catch (Exception) { imageSidesRezultImage.Insert(y + 1, new List <ImageSides>()); if (x == 0) { imageSidesRezultImage[y + 1].Add(imgNew); } else { for (int i = 0; i <= x; i++) { imageSidesRezultImage[y + 1].Add(null); } imageSidesRezultImage[y + 1][x] = imgNew; } } y++; LockSide(x, y); break; } case Side.Bot: //Top to the Base one { try { var sms = imageSidesRezultImage[y - 1]; // try if we have enouth lists over our if (sms.Count - 1 >= x) //we have place { imageSidesRezultImage[y - 1][x] = imgNew; } else { //we have row but no place under for (int i = imageSidesRezultImage[y - 1].Count; i <= x; i++) { imageSidesRezultImage[y - 1].Add(null); } imageSidesRezultImage[y - 1][x] = imgNew; } } catch (Exception) // if y == 0 { imageSidesRezultImage.Insert(0, new List <ImageSides>()); if (x == 0) { imageSidesRezultImage[y].Add(imgNew); } else { for (int i = 0; i < x; i++) { imageSidesRezultImage[y].Add(null); } imageSidesRezultImage[y][x] = imgNew; } } y--; LockSide(x, y); break; } case Side.Left: //Right to the Base one { try { var sms = imageSidesRezultImage[y][x + 1]; // try if we have enouth place in right side imageSidesRezultImage[y][x + 1] = imgNew; } catch (Exception) { imageSidesRezultImage[y].Add(imgNew); } x++; LockSide(x, y); break; } case Side.Right: //Left to the Base one { try { var sms = imageSidesRezultImage[y][x - 1]; // try if we have enouth space left to base one imageSidesRezultImage[y][x - 1] = imgNew; } catch (Exception) //case of x == 0 { imageSidesRezultImage[y].Insert(0, imgNew); foreach (var lists in imageSidesRezultImage) { if (imageSidesRezultImage.IndexOf(lists) != y) { lists.Insert(0, null); } } } LockSide(x, y); break; } } }