private async void CutOffIris1_Button(object sender, RoutedEventArgs e) { if (!(newBmp != null && newBmpTbl != null) && !(newBmp2 != null && newBmpTbl2 != null)) { MessageBox.Show("Load image!"); return; } BlakWait.Visibility = Visibility.Visible; if (newBmpTbl != null && !pic1Calculated) { await CutOffIris(0); } if (newBmpTbl2 != null && !pic2Calculated) { await CutOffIris(1); } BlakWait.Visibility = Visibility.Collapsed; if (newBmpTbl != null && !pic1Calculated) { img.Source = newBmpTbl.ToBitmapSource(); } if (newBmpTbl2 != null && !pic2Calculated) { img2.Source = newBmpTbl2.ToBitmapSource(); } Console.WriteLine("Done."); }
private async void Lines1_Button(object sender, RoutedEventArgs e) { if ((!(newBmp != null && newBmpTbl != null) && pupilR != 0 && irisR != 0) && !(newBmp2 != null && newBmpTbl2 != null) && pupilR2 != 0 && irisR2 != 0) { MessageBox.Show("Load image!"); return; } BlakWait.Visibility = Visibility.Visible; if ((newBmp != null && newBmpTbl != null) && pupilR != 0 && irisR != 0 && !pic1Calculated) { newBmpTbl = new ByteImage(originalBitmapTbl); await RunGreyScale(0); await DrawLines(0); newBmpTbl = new ByteImage(originalBitmapTbl); await CutOffStuff(0); img.Source = newBmpTbl.ToBitmapSource(); code.Source = codeBitmapTbl.ToBitmapSource(); pic1Calculated = true; } if ((newBmp2 != null && newBmpTbl2 != null) && pupilR2 != 0 && irisR2 != 0 && !pic2Calculated) { newBmpTbl2 = new ByteImage(originalBitmapTbl2); await RunGreyScale(1); await DrawLines(1); newBmpTbl2 = new ByteImage(originalBitmapTbl2); await CutOffStuff(1); img2.Source = newBmpTbl2.ToBitmapSource(); code2.Source = codeBitmapTbl2.ToBitmapSource(); pic2Calculated = true; } BlakWait.Visibility = Visibility.Collapsed; Console.WriteLine("Test."); }
private async Task CutOffIris(int mode) { if (mode == 0) { VERYBAD: pupilX = 0; pupilY = 0; pupilR = 0; irisX = 0; irisY = 0; irisR = 0; newBmpTbl = new ByteImage(originalBitmapTbl); await RunGreyScale(0); await ThreeColors(0); for (int i = 0; i < 2; i++) { await RunGaussFilter(0); await RunBlack(0); } await RunRemoveSingleNoises(0); await Task.Run(() => { Tuple <int, int, int> PupCenter = Helper.PupilCenter(borderColor, newBmpTbl); pupilX = PupCenter.Item1; pupilY = PupCenter.Item2; pupilR = PupCenter.Item3; }); //-------------- newBmpTbl = new ByteImage(originalBitmapTbl); await RunContrast(0); await RunGreyScale(0); await RunContrast(0); await RunGaussFilter(0); await RunBlack(0); await FiveColors(0); //await RunFullBlack(); await RunRemoveSingleNoises(0); await Task.Run(() => { Tuple <int, int, int> IrisCenter = Helper.Iris(borderIrisColor, newBmpTbl, pupilX, pupilY, pupilR); irisX = IrisCenter.Item1; irisY = IrisCenter.Item2; irisR = IrisCenter.Item3; }); if (irisR == -1) { goto VERYBAD; } newBmpTbl = new ByteImage(originalBitmapTbl); await CutOffStuff(0); img.Source = newBmpTbl.ToBitmapSource(); } else if (mode == 1) { VERYBAD2: pupilX2 = 0; pupilY2 = 0; pupilR2 = 0; irisX2 = 0; irisY2 = 0; irisR2 = 0; newBmpTbl2 = new ByteImage(originalBitmapTbl2); await RunGreyScale(1); await ThreeColors(1); for (int i = 0; i < 2; i++) { await RunGaussFilter(1); await RunBlack(1); } await RunRemoveSingleNoises(1); await Task.Run(() => { Tuple <int, int, int> PupCenter = Helper.PupilCenter(borderColor2, newBmpTbl2); pupilX2 = PupCenter.Item1; pupilY2 = PupCenter.Item2; pupilR2 = PupCenter.Item3; }); //-------------- newBmpTbl2 = new ByteImage(originalBitmapTbl2); await RunContrast(1); await RunGreyScale(1); await RunContrast(1); await RunGaussFilter(1); await RunBlack(1); await FiveColors(1); //await RunFullBlack(); await RunRemoveSingleNoises(1); await Task.Run(() => { Tuple <int, int, int> IrisCenter = Helper.Iris(borderIrisColor2, newBmpTbl2, pupilX2, pupilY2, pupilR2); irisX2 = IrisCenter.Item1; irisY2 = IrisCenter.Item2; irisR2 = IrisCenter.Item3; }); if (irisR2 == -1) { goto VERYBAD2; } newBmpTbl2 = new ByteImage(originalBitmapTbl2); await CutOffStuff(1); img2.Source = newBmpTbl2.ToBitmapSource(); } }