<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace Imageprocessing
{
    class Processing
    {
        public Processing()
        {

        }
        public static bool ConvertToGray(Bitmap B)
        {
            for (int i = 0; i < B.Width; i++)
                for (int j = 0; j < B.Height; j++)
                {
                    Color c1 = B.GetPixel(i, j);
                    int r1 = c1.R;
                    int g1 = c1.G;
                    int b1 = c1.B;
                    int gray = (byte)(.299 * r1 + .587 * g1 + .114 * b1);
                    r1 = gray;
                    g1 = gray;
                    b1 = gray;
                    B.SetPixel(i, j, Color.FromArgb(r1, g1, b1));
                }
            return true;
                }
        }
    }

<file_sep># How-to-convert-an-image-into-gray-scale-using-C-sharp
Image processing using C sharp.

In order to convert the image into gray scale you will need to perform these two steps for this application.
When you run the program, click on he open button to upload the image you want to convert them into grayscale scale.
After uploading the image click on the button gray scale. then you will get the result into in grayscale image.
<file_sep>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Imageprocessing
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofile = new OpenFileDialog();
            ofile.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*";
            if(DialogResult.OK==ofile.ShowDialog())
            {
                this.PicOriginal.Image = new Bitmap(ofile.FileName);

            }
        }

        private void btngray_Click(object sender, EventArgs e)
        {
            Bitmap copy = new Bitmap((Bitmap)this.PicOriginal.Image);
            Processing.ConvertToGray(copy);
            this.PicResult.Image = copy;
        }
    }
}
