using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Resources;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace YuksekAtesOlcumu
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Bitmap after, before;
        double ortR_after, ortG_after, ortB_after;
        double ortR_before, ortG_before, ortB_before;
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            after = (Bitmap)pictureBox1.Image;
            before = (Bitmap)pictureBox2.Image;

            //after görüntü için renk ortalama hesaplama
            for (int i = 0; i < after.Width; i++)
            {
                for (int j = 0; j < after.Height; j++)
                {
                    ortR_after += after.GetPixel(i, j).R;
                    ortG_after += after.GetPixel(i, j).G;
                    ortB_after += after.GetPixel(i, j).B;
                }
            }

            ortR_after = ortR_after / (after.Width * after.Height);
            ortG_after = ortG_after / (after.Width * after.Height);
            ortB_after = ortB_after / (after.Width * after.Height);

            //before görüntü için renk ortalama hesaplama

            for (int i = 0; i < before.Width; i++)
            {
                for (int j = 0; j < before.Height; j++)
                {
                    ortR_before += before.GetPixel(i, j).R;
                    ortG_before += before.GetPixel(i, j).G;
                    ortB_before += before.GetPixel(i, j).B;
                }
            }

            ortR_before = ortR_before / (before.Width * before.Height);
            ortG_before = ortG_before / (before.Width * before.Height);
            ortB_before = ortB_before / (before.Width * before.Height);

            // Sonucun Bulunması

            textBox1.Text = Math.Abs(100-(ortR_before / ortR_after * 100)).ToString();
            textBox2.Text = Math.Abs(100-(ortG_before / ortG_after * 100)).ToString();
            textBox3.Text = Math.Abs(100-(ortB_before / ortB_after * 100)).ToString();
        }
    }
}
