TUTORİAL - Find the similarity between two images with C#

in #utopian-io7 years ago (edited)

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 )
Adsız.png


Code Design;
Important : using.System.Collections; "Do not forget to add your class"
Kod Ekranı.png


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;
Başlıksız-3.png


Test 1 ;
Başlıksız-4.png

Test 2 ;
test1.png


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.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

The @OriginalWorks bot has determined this post by @shankstaicho to be original material and upvoted it!

ezgif.com-resize.gif

To call @OriginalWorks, simply reply to any post with @originalworks or !originalworks in your message!

Güzel ama ingiliççe :D

Yine süpersin abi ...

ELLERİNE SAĞLIK HOCAM

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

I thank you very much sir is a honor for me @deathwing

Hey @shankstaicho I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.030
BTC 58802.33
ETH 3158.99
USDT 1.00
SBD 2.42