private static void MarkEndings(int x, int y) { int counterForEnding = 0; int[] blacksInSquare3 = MinutiaeHelpers.GetArrayOfBlacksSquare3(x, y, _intPixels); foreach (var pixel in blacksInSquare3) { bool square3 = false; if (pixel == 1) { square3 = true; } if (pixel == 0 && square3) { counterForEnding++; } } Debug.WriteLine(counterForEnding); }
public static BitmapSource CheckForPotentialMinutia(BitmapSource source, int x, int y) { WriteableBitmap bitmap = new WriteableBitmap(source); _width = bitmap.PixelWidth; _height = bitmap.PixelHeight; _stride = _width * ((bitmap.Format.BitsPerPixel + 7) / 8); var arraySize = _stride * _height; _pixels = new byte[arraySize]; int countForSquare5 = 0, countForSquare9 = 0; bool square5 = false, square9 = false; //copy all data about pixels values into 1-dimentional array bitmap.CopyPixels(_pixels, _stride, 0); _tempPixels = _pixels; InitIntImage(); _tempIntPixels = _intPixels; int[] blacksInSquare5 = MinutiaeHelpers.GetArrayOfBlacksSquare5(x, y, _intPixels); int[] blacksInSquare9 = MinutiaeHelpers.GetArrayOfBlacksSquare9(x, y, _intPixels); foreach (var pixel in blacksInSquare5) { Debug.Write(pixel + " "); if (pixel == 1) { square5 = true; } if (pixel == 0 && square5) { countForSquare5++; square5 = false; } } foreach (var pixel in blacksInSquare9) { if (pixel == 1) { square9 = true; } if (pixel == 0 && square9) { countForSquare9++; square9 = false; } } MarkEndings(x, y); Debug.WriteLine(""); Debug.WriteLine(countForSquare5 + " " + countForSquare9); Debug.WriteLine(""); Debug.WriteLine(""); Debug.WriteLine(""); if (countForSquare5 == 3 && countForSquare9 == 3) { _intPixels[x, y] = 2; } RevertIntPixelsIntoPixelArray(); var rect = new Int32Rect(0, 0, _width, _height); bitmap.WritePixels(rect, _pixels, _stride, 0); return(bitmap); }
public static BitmapSource MarkMinuties(BitmapSource source) { var bitmap = new WriteableBitmap(source); _width = bitmap.PixelWidth; _height = bitmap.PixelHeight; _stride = _width * ((bitmap.Format.BitsPerPixel + 7) / 8); var arraySize = _stride * _height; _pixels = new byte[arraySize]; //copy all data about pixels values into 1-dimentional array bitmap.CopyPixels(_pixels, _stride, 0); InitIntImage(); _tempIntPixels = new int[_width, _height]; for (var i = 0; i < _width; i++) { for (var j = 0; j < _height; j++) { _tempIntPixels[i, j] = _intPixels[i, j]; } } for (var x = 0; x < _width; x++) { for (var y = 0; y < _height; y++) { int countForSquare5 = 0, countForSquare9 = 0; bool square5 = false, square9 = false; if (_intPixels[x, y] != 1) { continue; } var blacksInSquare5 = MinutiaeHelpers.GetArrayOfBlacksSquare5(x, y, _intPixels); var blacksInSquare9 = MinutiaeHelpers.GetArrayOfBlacksSquare9(x, y, _intPixels); foreach (var pixel in blacksInSquare5) { if (pixel == 1) { square5 = true; } if (pixel == 0 && square5) { countForSquare5++; square5 = false; } } foreach (var pixel in blacksInSquare9) { if (pixel == 1) { square9 = true; } if (pixel == 0 && square9) { countForSquare9++; square9 = false; } } //MarkEndings(x, y); //if both squares are crossovers exactly 3 times if (countForSquare5 == 3 && countForSquare9 == 3) { _tempIntPixels[x, y] = 2; } } } RevertIntPixelsIntoPixelArray(); RevertTempIntPixelsIntoArray(); var rect = new Int32Rect(0, 0, _width, _height); bitmap.WritePixels(rect, _pixels, _stride, 0); return(bitmap); }