TUTORİAL - Find the similarity between two images with C#
utopian-io·@shankstaicho·
0.000 HBDTUTORİAL - Find the similarity between two images with C#
I am introducing a program that I code today (the program belongs to me) The program helps to find the similarity between the two pictures :) > Use; After opening the program, we select 2 pictures with the select buttons on the left and right, Then we compare the start button with the 2 photos and the result is reflected in our screen. Do not hesitate to comment if you encounter any problems . GitHub Link : https://github.com/ShanksTaicho/PhotoSimilarityFinding > Overall design image of the program; (ToolBox : 2 groupBox, 2 pictureBox , 3 Button , 1 Label and openDialog )  ----------------------------------------------------------------------------------------------------------------------------- > Code Design; Important : using.System.Collections; "Do not forget to add your class"  ----------------------------------------------------------------------------------------------------------------------------- > Codes to select our pictures from your computer and bring them to the screen. (The code to be written into the button on the left side ) Bitmap bmp1, bmp2; ArrayList arl = new ArrayList(); ArrayList arl2 = new ArrayList(); private void button1_Click(object sender, EventArgs e) { arl.Clear(); openFileDialog1.ShowDialog(); bmp1 = (Bitmap)Bitmap.FromFile(openFileDialog1.FileName); pictureBox1.Image = bmp1; for(int a=0;a<bmp1.Width;a++) { for(int b=0;b<bmp1.Height;b++) { arl.Add(bmp1.GetPixel(a, b).Name); } } } ----------------------------------------------------------------------------------------------------------------------------- > We do the same for Button 2 for the operations we did for Button 1. (The code to be written into the button on the Right side ) private void button2_Click(object sender, EventArgs e) { arl2.Clear(); openFileDialog1.ShowDialog(); bmp2 = (Bitmap)Bitmap.FromFile(openFileDialog1.FileName); pictureBox2.Image = bmp2; for (int a =0;a<bmp2.Width;a++) { for (int b = 0;b<bmp2.Height;b++) { arl2.Add(bmp2.GetPixel(a, b).Name); } } } ----------------------------------------------------------------------------------------------------------------------------- > The actual code we will use for comparison private void button3_Click(object sender, EventArgs e) { double equal = 0; double notequal =0; for (int a = 0; a < arl.Count; a++) { if (arl [a].ToString() == arl2 [a].ToString()) { equal++; } else { notequal++; } } if (notequal ==0) { label1.Text = "%100"; } else { if (equal>notequal) { label1.Text = "%" + Convert.ToString(100 - ((notequal * 100) / equal)).Substring(0, 5); } else { label1.Text = "%" + Convert.ToString((equal * 100) / notequal).Substring(0, 5); } } } ----------------------------------------------------------------------------------------------------------------------------- > Result;  ----------------------------------------------------------------------------------------------------------------------------- > Test 1 ;  > Test 2 ;  ----------------------------------------------------------------------------------------------------------------------------- it will be a useful program for you, you can develop my program in more detail . The program's working logic sets the similarity rate by comparing the pixels of 2 photographs. I hope it is useful for you, I tried to get to introduce my program and clarify which codes are used. If you have a problem or suggestions somewhere, please comment. <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@shankstaicho/tutorial-find-the-similarity-between-two-images-with-c">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>