/// <summary> /// /// </summary> /// <param name="Absolute"></param> /// <returns></returns> static public BrighterDirection[,] GetRelativeImageIntensity(byte[,] Absolute) { int Width = Absolute.GetLength(0), Height = Absolute.GetLength(1); var Relative = new BrighterDirection[Width, Height]; int[] XList = new int[3], YList = new int[3]; for (int CurrentY = 0; CurrentY < Height; CurrentY++) { YList[0] = (CurrentY == 0) ? (Height - 1) : (CurrentY - 1); YList[1] = CurrentY; YList[2] = (CurrentY == Height - 1) ? (0) : (CurrentY + 1); for (int CurrentX = 0; CurrentX < Width; CurrentX++) { XList[0] = (CurrentX == 0) ? (Width - 1) : (CurrentX - 1); XList[1] = CurrentX; XList[2] = (CurrentX == Width - 1) ? (0) : (CurrentX + 1); byte CurrentRelative = 0; var Current = Absolute[CurrentX, CurrentY]; byte Bit = 1; foreach (var NearY in YList) { foreach (var NearX in XList) { // Ignore Center if (NearX == 0 && NearY == 0) { continue; } var Near = Absolute[NearX, NearY]; if (Current > Near) { CurrentRelative |= Bit; } Bit <<= 1; } } Relative[CurrentX, CurrentY] = (BrighterDirection)CurrentRelative; } } return(Relative); }
/// <summary> /// /// </summary> /// <param name="Absolute"></param> /// <returns></returns> public static BrighterDirection[,] GetRelativeImageIntensity(byte[,] Absolute) { int Width = Absolute.GetLength(0), Height = Absolute.GetLength(1); var Relative = new BrighterDirection[Width, Height]; int[] XList = new int[3], YList = new int[3]; for (int CurrentY = 0; CurrentY < Height; CurrentY++) { YList[0] = (CurrentY == 0) ? (Height - 1) : (CurrentY - 1); YList[1] = CurrentY; YList[2] = (CurrentY == Height - 1) ? (0) : (CurrentY + 1); for (int CurrentX = 0; CurrentX < Width; CurrentX++) { XList[0] = (CurrentX == 0) ? (Width - 1) : (CurrentX - 1); XList[1] = CurrentX; XList[2] = (CurrentX == Width - 1) ? (0) : (CurrentX + 1); byte CurrentRelative = 0; var Current = Absolute[CurrentX, CurrentY]; byte Bit = 1; foreach (var NearY in YList) foreach (var NearX in XList) { // Ignore Center if (NearX == 0 && NearY == 0) continue; var Near = Absolute[NearX, NearY]; if (Current > Near) { CurrentRelative |= Bit; } Bit <<= 1; } Relative[CurrentX, CurrentY] = (BrighterDirection)CurrentRelative; } } return Relative; }