public void StartNegative(BitmapImage image)
        {
            var bitmapConverter = new BitmapImageToBitmapConverter();
            var mConvertBitmap = (Bitmap)bitmapConverter.ConvertBack(image, null, null, null);

            int w_b = mConvertBitmap.Width;
            int h_b = mConvertBitmap.Height;

            int k = 1, maxValue = w_b;
            double curValue = 0;

            for (int x = 0; x < w_b; x++)
            {
                for (int y = 0; y < h_b; y++)
                {
                    Color c = mConvertBitmap.GetPixel(x, y);
                    mConvertBitmap.SetPixel(x, y, Color.FromArgb(255 - c.R, 255 - c.G, 255 - c.B));
                }
                //curValue = k / maxValue;
                //_processBarValue(k, (int)curValue);
                //k++;

            }

            var bitmapImageConverter = new BitmapImageToBitmapConverter();
            var mBTImage = (BitmapImage)bitmapImageConverter.Convert(mConvertBitmap, null, null, null);

            _delMessage(mBTImage);

            const string message = "Преобразование завершено!";
            const string caption = "Завершение";

            const MessageBoxButtons buttons = MessageBoxButtons.OK;
            MessageBox.Show(message, caption, buttons);
        }
        public void StartMedianFilter(int value, BitmapImage mBitmap)
        {
            var bitmapConverter = new BitmapImageToBitmapConverter();
            var mConvertBitmap = (Bitmap)bitmapConverter.ConvertBack(mBitmap, null, null, null);

            int w_b = mConvertBitmap.Width;
            int h_b = mConvertBitmap.Height;
            int k = 1, maxValue = w_b*h_b;
            double curValue=0;

            for (int x = value; x < w_b - value; x++)
            {
                for (int y = value; y < h_b - value; y++)
                {
                    MedianFilter(mConvertBitmap, x, y, value);
                    //curValue = k * 100 / maxValue;
                    //_processBarValue(k, (int) curValue);
                    //k++;
                }
            }

            var bitmapImageConverter = new BitmapImageToBitmapConverter();
            var mBTImage = (BitmapImage)bitmapImageConverter.Convert(mConvertBitmap, null, null, null);

            _delMessage(mBTImage);

            const string message = "Фильтрация завершена!";
            const string caption = "Завершение";

            const MessageBoxButtons buttons = MessageBoxButtons.OK;
            MessageBox.Show(message, caption, buttons);
        }
        public void StartEqualize(BitmapImage mBitmap)
        {
            var bitmapConverter = new BitmapImageToBitmapConverter();
            var mConvertBitmap = (Bitmap) bitmapConverter.ConvertBack(mBitmap, null, null, null);

            int w_b = mConvertBitmap.Width;
            int h_b = mConvertBitmap.Height;

            Color minColor = mConvertBitmap.GetPixel(0, 0), maxColor = mConvertBitmap.GetPixel(0, 0);

            int minR = minColor.R, minG = minColor.G, minB = minColor.B;
            int maxR = maxColor.R, maxG = maxColor.G, maxB = maxColor.G;

            for (int i = 0; i < w_b; i++)
            {
                for (int j = 0; j < h_b; j++)
                {
                    Color curColor = mConvertBitmap.GetPixel(i, j);

                    //min value
                    if(curColor.R<minR)
                    {
                        minR = curColor.R;
                    }
                    if (curColor.G < minG)
                    {
                        minG = curColor.G;
                    }
                    if (curColor.B < minB)
                    {
                        minB = curColor.B;
                    }

                    //max value
                    if (curColor.R > maxR)
                    {
                        maxR = curColor.R;
                    }
                    if (curColor.G > maxG)
                    {
                        maxG = curColor.G;
                    }
                    if (curColor.B > maxB)
                    {
                        maxB = curColor.B;
                    }
                }
            }

            float b_R = 255/(maxR - minR);
            float b_G = 255/(maxG - minG);
            float b_B = 255/(maxB - minB);

            float a_R = -1*(b_R*minR);
            float a_G = -1*(b_G*minG);
            float a_B = -1*(b_B*minB);

            for (int i = 0; i < w_b; i++)
            {
                for (int j = 0; j < h_b; j++)
                {
                    Color c = mConvertBitmap.GetPixel(i, j);
                    mConvertBitmap.SetPixel(i, j, Color.FromArgb((int)(a_R + b_R * c.R), (int)(a_G + b_G * c.G), (int)(a_B + b_B * c.B)));
                }
            }

            var bitmapImageConverter = new BitmapImageToBitmapConverter();
            var mBTImage = (BitmapImage)bitmapImageConverter.Convert(mConvertBitmap, null, null, null);

            _eqMessage(mBTImage);

            const string message = "Преобразование завершено!";
            const string caption = "Завершение";

            const MessageBoxButtons buttons = MessageBoxButtons.OK;
            MessageBox.Show(message, caption, buttons);
        }
        private void NegetiveClick(object sender, RoutedEventArgs e)
        {
            var bitmapConverter = new BitmapImageToBitmapConverter();
            Bitmap mConvertBitmap = (Bitmap)bitmapConverter.ConvertBack(_mBtImage, null, null, null);

            int w_b = mConvertBitmap.Width;
            int h_b = mConvertBitmap.Height;

            filterProcessBar.Maximum = w_b * h_b;
            maxValueProcessBar = w_b * h_b;

            var thread = new Thread(() => _mNegCal.StartNegative(_mBtImage));
            thread.Start();

            MedianFilterItem.IsEnabled = false;
            NegativItem.IsEnabled = false;
            EqualizeItem.IsEnabled = false;

            OpenItem.IsEnabled = false;
        }
        private void EqualizeClick(object sender, RoutedEventArgs e)
        {
            var bitmapConverter = new BitmapImageToBitmapConverter();
            Bitmap mConverterBitmap = (Bitmap) bitmapConverter.ConvertBack(_mBtImage, null, null, null);

            int w_b = mConverterBitmap.Width;
            int h_b = mConverterBitmap.Height;

            var thread = new Thread(() => _mEqCal.StartEqualize(_mBtImage));
            thread.Start();

            MedianFilterItem.IsEnabled = false;
            NegativItem.IsEnabled = false;
            EqualizeItem.IsEnabled = false;

            OpenItem.IsEnabled = false;
        }