public static ResultInfo pFind(Bitmap bmp, Bitmap bmp1) { ArrayList m_list = new ArrayList(); for (int ii = 0; ii < bmp.Width - bmp1.Width; ii++) { for (int j = 0; j < bmp.Height - bmp1.Height; j++) { Rectangle rect = new Rectangle(ii, j, bmp1.Width, bmp1.Height); int res = 0; for (int k2 = 0; k2 < bmp1.Width; k2++) { for (int j2 = 0; j2 < bmp1.Height; j2++) { Color color1 = bmp.GetPixel(ii + k2, j + j2); Color color2 = bmp1.GetPixel(k2, j2); res += (color1.R - color2.R) * (color1.R - color2.R); } } if (res < 2000000) { ResultInfo data = new ResultInfo(); data.x = ii; data.y = j; data.score = res; m_list.Add(data); } } } ResultInfoAscent sa = new ResultInfoAscent(); m_list.Sort(sa); return((ResultInfo)m_list[0]); }
public static void FindP2(Image i1, Image i2) { Bitmap bmp1 = (Bitmap)ReduceSize(i1, i1.Width / 12, i1.Height / 12); Bitmap bmp2 = (Bitmap)ReduceSize(i2, i2.Width / 12, i2.Height / 12); bmp1.Save("C:\\temp\\tPicture3.bmp", System.Drawing.Imaging.ImageFormat.Bmp); ArrayList m_list = new ArrayList(); for (int ii = 0; ii < bmp1.Width - bmp2.Width; ii++) { for (int j = 0; j < bmp1.Height - bmp2.Height; j++) { Rectangle rect = new Rectangle(ii, j, bmp2.Width, bmp2.Height); Bitmap tbmp = (Bitmap)AcquireRectangleImage(bmp1, rect); Int32 res = CalcSimilarDegree2(tbmp, bmp2); if (res < bmp2.Width * bmp2.Height / 2) { ResultInfo data = new ResultInfo(); data.x = ii; data.y = j; data.score = res; m_list.Add(data); } } } ResultInfoAscent sa = new ResultInfoAscent(); m_list.Sort(sa); int i = 0; while (i < m_list.Count) { int j = i + 1; while (j < m_list.Count) { int tx = ((ResultInfo)m_list[i]).x - ((ResultInfo)m_list[j]).x; int ty = ((ResultInfo)m_list[i]).y - ((ResultInfo)m_list[j]).y; if (tx * tx + ty * ty < bmp2.Width * bmp2.Height) { m_list.RemoveAt(j); } else { j++; } } i++; } }
public static ArrayList FindP(Image i1) { Bitmap bmp = (Bitmap)i1.Clone(); bmp.Save(@"C:\temp\Picture1.bmp"); Bitmap bmp1 = (Bitmap)Image.FromFile(@"C:\temp\qj.bmp"); Bitmap bmp2 = (Bitmap)Image.FromFile(@"C:\temp\zj.bmp"); Bitmap bmp3 = (Bitmap)Image.FromFile(@"C:\temp\hm.bmp"); //Bitmap bmp4 = (Bitmap)Image.FromFile(@"D:\Downloads\Compressed\SimpleWindowCapture-master\res\ysc.bmp"); Bitmap bmp5 = (Bitmap)Image.FromFile(@"C:\temp\boss.bmp"); Zoom(bmp, 0.1, 0.1, out bmp); Zoom(bmp1, 0.1, 0.1, out bmp1); Zoom(bmp2, 0.1, 0.1, out bmp2); Zoom(bmp3, 0.1, 0.1, out bmp3); //Zoom(bmp4, 0.1, 0.1, out bmp4); Zoom(bmp5, 0.1, 0.1, out bmp5); ArrayList m_list1 = FindEm2(1, bmp, bmp1); ArrayList m_list2 = FindEm2(2, bmp, bmp2); ArrayList m_list3 = FindEm2(3, bmp, bmp3); //ArrayList m_list4 = FindEm2(4, bmp, bmp4); ArrayList m_list5 = FindEm2(5, bmp, bmp5); ArrayList m_list = m_list1; for (int ti = 0; ti < m_list2.Count; ti++) { m_list.Add(m_list2[ti]); } for (int ti = 0; ti < m_list3.Count; ti++) { m_list.Add(m_list3[ti]); } //for (int ti = 0; ti < m_list4.Count; ti++) // m_list.Add(m_list4[ti]); for (int ti = 0; ti < m_list5.Count; ti++) { m_list.Add(m_list5[ti]); } ResultInfoAscent sa = new ResultInfoAscent(); m_list.Sort(sa); return(m_list); }
public static ArrayList FindEm2(int type, Bitmap re1, Bitmap re2) { Bitmap res1 = (Bitmap)re1.Clone(); Bitmap ress1 = (Bitmap)res1.Clone(); Bitmap res2 = (Bitmap)re2.Clone(); Bitmap ress2 = (Bitmap)res2.Clone(); BlackWhite2(res1); BlackWhite2(res2); int recw = res2.Width; int rech = res2.Height; int[,] map = new int[res1.Width, res1.Height]; int[,] map2 = new int[res1.Width, res1.Height]; map[0, 0] = res1.GetPixel(0, 0).R; map2[0, 0] = res1.GetPixel(0, 0).R *res1.GetPixel(0, 0).R; int org = 0; int org2 = 0; for (int ii = 0; ii < res2.Width; ii++) { for (int jj = 0; jj < res2.Height; jj++) { org += res2.GetPixel(ii, jj).R; org2 += res2.GetPixel(ii, jj).R *res2.GetPixel(ii, jj).R; } } org = org / (res2.Width * res2.Height); org2 = org2 / (res2.Width * res2.Height); org2 = org2 - org * org; int i = 1; int j = 1; while (i < res1.Width && j < res1.Height) { map[0, j] = map[0, j - 1] + res1.GetPixel(0, j).R; map2[0, j] = map2[0, j - 1] + map2[0, j] + res1.GetPixel(0, j).R *res1.GetPixel(0, j).R; for (int ii = 1; ii < i; ii++) { map[ii, j] = map[ii, j - 1] + map[ii - 1, j] - map[ii - 1, j - 1] + res1.GetPixel(ii, j).R; map2[ii, j] = map2[ii, j - 1] + map2[ii - 1, j] - map2[ii - 1, j - 1] + res1.GetPixel(ii, j).R *res1.GetPixel(ii, j).R; } map[i, 0] = map[i - 1, 0] + res1.GetPixel(i, 0).R; map2[i, 0] = map2[i - 1, 0] + res1.GetPixel(i, 0).R *res1.GetPixel(i, 0).R; for (int jj = 1; jj < j; jj++) { map[i, jj] = map[i, jj - 1] + map[i - 1, jj] - map[i - 1, jj - 1] + res1.GetPixel(i, jj).R; map2[i, jj] = map2[i, jj - 1] + map2[i - 1, jj] - map2[i - 1, jj - 1] + res1.GetPixel(i, jj).R *res1.GetPixel(i, jj).R; } map[i, j] = map[i, j - 1] + map[i - 1, j] - map[i - 1, j - 1] + res1.GetPixel(i, j).R; map2[i, j] = map2[i, j - 1] + map2[i - 1, j] - map2[i - 1, j - 1] + res1.GetPixel(i, j).R *res1.GetPixel(i, j).R; i++; j++; } i--; j--; while (i < res1.Width && j == res1.Height - 1) { map[i, 0] = map[i - 1, 0] + res1.GetPixel(i, 0).R; map2[i, 0] = map2[i - 1, 0] + res1.GetPixel(i, 0).R *res1.GetPixel(i, 0).R; for (int jj = 1; jj <= j; jj++) { map[i, jj] = map[i, jj - 1] + map[i - 1, jj] - map[i - 1, jj - 1] + res1.GetPixel(i, jj).R; map2[i, jj] = map2[i, jj - 1] + map2[i - 1, jj] - map2[i - 1, jj - 1] + res1.GetPixel(i, jj).R *res1.GetPixel(i, jj).R; } i++; } while (j < res1.Height && i == res1.Width - 1) { map[0, j] = map[0, j - 1] + res1.GetPixel(0, j).R; map2[0, j] = map2[0, j - 1] + res1.GetPixel(0, j).R *res1.GetPixel(0, j).R; for (int ii = 1; ii <= i; ii++) { map[ii, j] = map[ii, j - 1] + map[ii - 1, j] - map[ii - 1, j - 1] + res1.GetPixel(ii, j).R; map2[ii, j] = map2[ii, j - 1] + map2[ii - 1, j] - map2[ii - 1, j - 1] + res1.GetPixel(ii, j).R *res1.GetPixel(ii, j).R; } j++; } ArrayList m_list = new ArrayList(); for (i = res2.Width; i < res1.Width; i++) { for (j = res2.Height; j < res1.Height; j++) { int t = map[i, j] - map[i - res2.Width, j] - map[i, j - res2.Height] + map[i - res2.Width, j - res2.Height]; int t2 = map2[i, j] - map2[i - res2.Width, j] - map2[i, j - res2.Height] + map2[i - res2.Width, j - res2.Height]; t = t / (res2.Width * res2.Height); t2 = t2 / (res2.Width * res2.Height); t2 = t2 - t * t; if (i == 69 && j == 58) { i = i; } if (Math.Abs(org - t) < 20 && Math.Abs(org2 - t2) < 1000) { Color c = res1.GetPixel(i, j); int res = 0; for (int ii = i - res2.Width; ii < i; ii++) { for (int jj = j - res2.Height; jj < j; jj++) { int R = Math.Abs(ress1.GetPixel(ii, jj).R - ress2.GetPixel(ii - i + ress2.Width, jj - j + ress2.Height).R); int G = Math.Abs(ress1.GetPixel(ii, jj).G - ress2.GetPixel(ii - i + ress2.Width, jj - j + ress2.Height).G); int B = Math.Abs(ress1.GetPixel(ii, jj).B - ress2.GetPixel(ii - i + ress2.Width, jj - j + ress2.Height).B); int lt = Math.Max(R, Math.Max(G, B)); lt = lt / 10; lt = lt * lt * lt; lt = lt / 10; res += lt * lt; } } res = res / (res2.Width * res2.Height); if (res < 2000) { ResultInfo data = new ResultInfo(); data.x = i - res2.Width / 2; data.y = j - res2.Height / 2; data.type = type; data.score = res; m_list.Add(data); } } } } ResultInfoAscent sa = new ResultInfoAscent(); m_list.Sort(sa); i = 0; while (i < m_list.Count) { j = i + 1; while (j < m_list.Count) { int ttx = ((ResultInfo)m_list[i]).x - ((ResultInfo)m_list[j]).x; int tty = ((ResultInfo)m_list[i]).y - ((ResultInfo)m_list[j]).y; if (ttx * ttx + tty * tty < res2.Width * res2.Height) { m_list.RemoveAt(j); } else { j++; } } i++; } return(m_list); }
public static ArrayList FindEm2(Image i1) { //Bitmap bmpt; //Zoom((Bitmap)i1, 0.3, 0.3, out bmpt); //Bitmap back = (Bitmap)i1.Clone(); //bmpt = ToGrayt(bmpt); //bmpt.Save(@"C:\Users\10947\Desktop\bmp.bmp"); bmp = ToGray((Bitmap)i1); //bmpt.Save(@"C:\Users\10947\Desktop\Picture2p.bmp"); em = ToGray((Bitmap)Image.FromFile(@"C:\Users\10947\Downloads\Compressed\SimpleWindowCapture-master\res\qj.bmp")); bmp.Save(@"C:\Users\10947\Desktop\bmp.bmp"); em.Save(@"C:\Users\10947\Desktop\em.bmp"); ArrayList m_list = new ArrayList(); for (int ii = 150; ii < bmp.Width - 100; ii++) { for (int j = 150; j < bmp.Height - 100; j++) { Color colort = bmp.GetPixel(ii, j); Color color1 = bmp.GetPixel(ii, j); Color color2 = em.GetPixel(em.Width / 2, em.Height / 2); if (color1.R == color2.R) { ResultInfo data = new ResultInfo(); data.x = ii; data.y = j; m_list.Add(data); } } } ResultInfoAscent sa = new ResultInfoAscent(); for (int ti = 1; ti < 20; ti++) { m_list = Prefind(ti, m_list); if (m_list.Count < 10) { break; } } m_list.Sort(sa); int i = 0; while (i < m_list.Count) { int j = i + 1; while (j < m_list.Count) { int ttx = ((ResultInfo)m_list[i]).x - ((ResultInfo)m_list[j]).x; int tty = ((ResultInfo)m_list[i]).y - ((ResultInfo)m_list[j]).y; if (ttx * ttx + tty * tty < em.Width * em.Height) { m_list.RemoveAt(j); } else { j++; } } i++; } return(m_list); }
public static ArrayList FindEm(Image i1) { Bitmap bmpt; Zoom((Bitmap)i1, 0.3, 0.3, out bmpt); Bitmap back = (Bitmap)i1.Clone(); bmpt = ToGrayt(bmpt); bmpt.Save(@"C:\Users\10947\Desktop\bmp.bmp"); Bitmap bmp = bmpt; //bmpt.Save(@"C:\Users\10947\Desktop\Picture2p.bmp"); Bitmap em = (Bitmap)Image.FromFile(@"C:\Users\10947\Desktop\Picturep.bmp"); ArrayList m_list = new ArrayList(); for (int ii = 150; ii < bmp.Width - 100; ii++) { for (int j = 150; j < bmp.Height - 100; j++) { Color colort = bmp.GetPixel(ii, j); if (colort.R == 0) { continue; } int res = 0; int soc = 0; for (int k2 = 0; k2 < em.Width; k2++) { for (int j2 = 0; j2 < em.Height; j2++) { Color color1 = bmp.GetPixel(ii + k2, j + j2); Color color2 = em.GetPixel(k2, j2); if (color1.R == color2.R) { res += 1; if (color1.R == 255) { soc++; } } } } if (res > 700) { ResultInfo data = new ResultInfo(); data.x = ii; data.y = j; data.score = res; m_list.Add(data); } } } ResultInfoAscent sa = new ResultInfoAscent(); m_list.Sort(sa); int i = 0; while (i < m_list.Count) { int j = i + 1; while (j < m_list.Count) { int ttx = ((ResultInfo)m_list[i]).x - ((ResultInfo)m_list[j]).x; int tty = ((ResultInfo)m_list[i]).y - ((ResultInfo)m_list[j]).y; if (ttx * ttx + tty * tty < em.Width * em.Height) { m_list.RemoveAt(j); } else { j++; } } int tx = ((ResultInfo)m_list[i]).x - 105; int ty = ((ResultInfo)m_list[i]).y - 125; Rectangle rect = new Rectangle(tx, ty, 50, 50); Bitmap tbmp = (Bitmap)AcquireRectangleImage(back, rect); tbmp = ToRed(tbmp); tbmp.Save(@"C:\Users\10947\Desktop\tbmp.bmp"); int dot = 0; for (int ii = 0; ii < 50; ii++) { for (int jj = 0; jj < 50; jj++) { Color c = tbmp.GetPixel(ii, jj); if (c.R == 255) { dot++; } } } if (dot < 210) { ((ResultInfo)m_list[i]).star = 1; } else if (dot < 230) { ((ResultInfo)m_list[i]).star = 2; } else { ((ResultInfo)m_list[i]).star = 3; } i++; } return(m_list); }
public static ArrayList FindP(Image i1) { Bitmap bmp = ToGray((Bitmap)i1); Bitmap bmp1 = (Bitmap)Image.FromFile(@"C:\Users\10947\Desktop\qj.bmp"); Bitmap bmp2 = (Bitmap)Image.FromFile(@"C:\Users\10947\Desktop\zj.bmp"); Bitmap bmp3 = (Bitmap)Image.FromFile(@"C:\Users\10947\Desktop\hm.bmp"); Bitmap bmp4 = (Bitmap)Image.FromFile(@"C:\Users\10947\Desktop\ysc.bmp"); Bitmap bmp5 = (Bitmap)Image.FromFile(@"C:\Users\10947\Desktop\boss.bmp"); Bitmap bmp6 = (Bitmap)Image.FromFile(@"C:\Users\10947\Desktop\wh.bmp"); Bitmap tb1 = (Bitmap)Image.FromFile(@"C:\Users\10947\Desktop\xj1.bmp"); Bitmap tb2 = (Bitmap)Image.FromFile(@"C:\Users\10947\Desktop\xj2.bmp"); Bitmap tb3 = (Bitmap)Image.FromFile(@"C:\Users\10947\Desktop\xj3.bmp"); tb1 = ToGray(tb1); tb2 = ToGray(tb2); tb3 = ToGray(tb3); bmp1 = ToGray(bmp1); bmp2 = ToGray(bmp2); bmp3 = ToGray(bmp3); bmp4 = ToGray(bmp4); bmp5 = ToGray(bmp5); bmp6 = ToGray(bmp6); Bitmap xbmp = (Bitmap)ReduceSize(i1, i1.Width / 5, i1.Height / 5); bmp = (Bitmap)ReduceSize(i1, i1.Width / 10, i1.Height / 10); bmp1 = (Bitmap)ReduceSize(bmp1, bmp1.Width / 10, bmp1.Height / 10); bmp2 = (Bitmap)ReduceSize(bmp2, bmp2.Width / 10, bmp2.Height / 10); bmp3 = (Bitmap)ReduceSize(bmp3, bmp3.Width / 10, bmp3.Height / 10); bmp4 = (Bitmap)ReduceSize(bmp4, bmp4.Width / 10, bmp4.Height / 10); bmp5 = (Bitmap)ReduceSize(bmp5, bmp5.Width / 10, bmp5.Height / 10); bmp6 = (Bitmap)ReduceSize(bmp6, bmp6.Width / 10, bmp6.Height / 10); //tb1.Save("C:\\temp\\tPicture1.bmp", System.Drawing.Imaging.ImageFormat.Bmp); //tb3.Save("C:\\temp\\tPicture3.bmp", System.Drawing.Imaging.ImageFormat.Bmp); tb1 = (Bitmap)ReduceSize(tb1, tb1.Width / 5, tb1.Height / 5); tb2 = (Bitmap)ReduceSize(tb2, tb2.Width / 5, tb2.Height / 5); tb3 = (Bitmap)ReduceSize(tb3, tb3.Width / 5, tb3.Height / 5); //xbmp.Save("C:\\temp\\tPicturex.bmp", System.Drawing.Imaging.ImageFormat.Bmp); //bmp5.Save("C:\\temp\\tPicture5.bmp", System.Drawing.Imaging.ImageFormat.Bmp); //tb3.Save("C:\\temp\\tPicture3.bmp", System.Drawing.Imaging.ImageFormat.Bmp); ArrayList m_list1 = tFind(1, bmp, bmp1, tb1, tb2, tb3, xbmp); ArrayList m_list2 = tFind(2, bmp, bmp2, tb1, tb2, tb3, xbmp); ArrayList m_list3 = tFind(3, bmp, bmp3, tb1, tb2, tb3, xbmp); ArrayList m_list4 = tFind(4, bmp, bmp4, tb1, tb2, tb3, xbmp); ArrayList m_list5 = tFind(5, bmp, bmp5, tb1, tb2, tb3, xbmp); ArrayList m_list6 = tFind(6, bmp, bmp6, tb1, tb2, tb3, xbmp); ArrayList m_list = m_list1; for (int ti = 0; ti < m_list2.Count; ti++) { m_list.Add(m_list2[ti]); } for (int ti = 0; ti < m_list3.Count; ti++) { m_list.Add(m_list3[ti]); } for (int ti = 0; ti < m_list4.Count; ti++) { m_list.Add(m_list4[ti]); } for (int ti = 0; ti < m_list5.Count; ti++) { m_list.Add(m_list5[ti]); } for (int ti = 0; ti < m_list6.Count; ti++) { m_list.Add(m_list6[ti]); } ResultInfoAscent sa = new ResultInfoAscent(); m_list.Sort(sa); return(m_list); }
public static ArrayList tFind(int type, Bitmap bmp1, Bitmap bmp2, Bitmap tb1, Bitmap tb2, Bitmap tb3, Bitmap xbmp) { ArrayList m_list = new ArrayList(); for (int ii = 0; ii < bmp1.Width - bmp2.Width; ii++) { for (int j = 0; j < bmp1.Height - bmp2.Height; j++) { Rectangle rect = new Rectangle(ii, j, bmp2.Width, bmp2.Height); int res = 0; for (int k2 = 0; k2 < bmp2.Width; k2++) { for (int j2 = 0; j2 < bmp2.Height; j2++) { Color color1 = bmp1.GetPixel(ii + k2, j + j2); Color color2 = bmp2.GetPixel(k2, j2); res += (color1.R - color2.R) * (color1.R - color2.R); } } if (res < 310000) { ResultInfo data = new ResultInfo(); data.x = ii; data.y = j; data.score = res; data.type = type; m_list.Add(data); } } } ResultInfoAscent sa = new ResultInfoAscent(); m_list.Sort(sa); if (type == 5) { m_list.RemoveRange(1, m_list.Count - 1); if (((ResultInfo)m_list[0]).score <= 210000) { ((ResultInfo)m_list[0]).star = -1; ((ResultInfo)m_list[0]).x = (((ResultInfo)m_list[0]).x + bmp2.Width / 2) * 10; ((ResultInfo)m_list[0]).y = (((ResultInfo)m_list[0]).y + bmp2.Height / 2) * 10; } else { m_list.Clear(); } return(m_list); } int i = 0; while (i < m_list.Count) { int j = i + 1; while (j < m_list.Count) { int ttx = ((ResultInfo)m_list[i]).x - ((ResultInfo)m_list[j]).x; int tty = ((ResultInfo)m_list[i]).y - ((ResultInfo)m_list[j]).y; if (ttx * ttx + tty * tty < bmp2.Width * bmp2.Height) { m_list.RemoveAt(j); } else { j++; } } if (type > 4) { ((ResultInfo)m_list[i]).star = -1; ((ResultInfo)m_list[i]).x = (((ResultInfo)m_list[i]).x + bmp2.Width / 2) * 10; ((ResultInfo)m_list[i]).y = (((ResultInfo)m_list[i]).y + bmp2.Height / 2) * 10; i++; continue; } int tx = ((ResultInfo)m_list[i]).x * 2 - 20; int ty = ((ResultInfo)m_list[i]).y * 2 - 20; ArrayList m_list2 = new ArrayList(); for (int ii = tx; ii < tx + 20; ii++) { for (int jj = ty; jj < ty + 20; jj++) { Rectangle rect = new Rectangle(ii, jj, 5, 5); ResultInfo data1 = new ResultInfo(); ResultInfo data2 = new ResultInfo(); ResultInfo data3 = new ResultInfo(); int res = 0; data1.x = ii; data1.y = jj; data1.type = -1; data2.x = ii; data2.y = jj; data2.type = -1; data3.x = ii; data3.y = jj; data3.type = -1; for (int k2 = 0; k2 < 10; k2++) { for (int j2 = 0; j2 < 10; j2++) { Color color1 = xbmp.GetPixel(ii + k2, jj + j2); Color color2 = tb1.GetPixel(k2, j2); res += (color1.R - color2.R) * (color1.R - color2.R); } } data1.score = res; data1.star = 1; m_list2.Add(data1); res = 0; for (int k2 = 0; k2 < 10; k2++) { for (int j2 = 0; j2 < 10; j2++) { Color color1 = xbmp.GetPixel(ii + k2, jj + j2); Color color2 = tb2.GetPixel(k2, j2); res += (color1.R - color2.R) * (color1.R - color2.R); } } data2.score = res; data2.star = 2; m_list2.Add(data2); res = 0; for (int k2 = 0; k2 < 10; k2++) { for (int j2 = 0; j2 < 10; j2++) { Color color1 = xbmp.GetPixel(ii + k2, jj + j2); Color color2 = tb3.GetPixel(k2, j2); res += (color1.R - color2.R) * (color1.R - color2.R); } } data3.score = res; data3.star = 3; m_list2.Add(data3); } } m_list2.Sort(sa); ((ResultInfo)m_list[i]).star = ((ResultInfo)m_list2[i]).star; ((ResultInfo)m_list[i]).x = (((ResultInfo)m_list[i]).x + bmp2.Width / 2) * 10; ((ResultInfo)m_list[i]).y = (((ResultInfo)m_list[i]).y + bmp2.Height / 2) * 10; i++; } return(m_list); }