private void B_Click(object sender, RoutedEventArgs e)
 {
     Thresh[] threshList = new Thresh[Nbt];
     Console.WriteLine("coucou");
     for (int i = 0; i < Nbt; i++)
     {
         threshList[i].min = ((IntegerUpDown)VisualTreeHelper.GetChild(sp, 4 * i + 1)).Value.Value;
         threshList[i].val = ((IntegerUpDown)VisualTreeHelper.GetChild(sp, 4 * i + 2)).Value.Value;
         threshList[i].max = ((IntegerUpDown)VisualTreeHelper.GetChild(sp, 4 * i + 3)).Value.Value;
     }
     Mainwindow.multiThreshHold(threshList);
     this.Close();
 }
        public static Bitmap Threshhold(Thresh t, Bitmap bmp)
        {
            Bitmap ret = new Bitmap(bmp);

            for (int i = 0; i < bmp.Width; i++)
            {
                for (int j = 0; j < bmp.Height; j++)
                {
                    int valeur = (bmp.GetPixel(i, j).R + bmp.GetPixel(i, j).G + bmp.GetPixel(i, j).B) / 3;
                    if (valeur < t.max && valeur >= t.min)
                    {
                        ret.SetPixel(i, j, System.Drawing.Color.FromArgb(t.val, t.val, t.val));
                    }
                }
            }

            return(ret);
        }