static void Print_Array(double[,] arr)
for (int row = 0; row < arr.GetLength(0); row++)
for (int col = 0; col < arr.GetLength(1); col++)
Console.WriteLine("Element({0},{1})={2}", row, col, arr[row, col]);
static void Print_Array_Row(double[,] arr, int row_no)
for (int row = 0; row < arr.GetLength(0); row++)
Console.WriteLine("Element({0})={1}", row, arr[row,row_no]);
static void Array_SetValue(double[,] arr, int offset_top_start, int offset_top_end, int offset_bot_start, int offset_bot_end, int Value)
for (int row = offset_top_start; row < arr.GetLength(0) - offset_top_end; row++)
for (int col = offset_bot_start; col < arr.GetLength(1) - offset_bot_end; col++)
static void random(int Value)
static void Array_rnd(double[,] arr, int rnd_start, int rnd_end)
for (int row = 0; row < arr.GetLength(0) - 0; row++)
for (int col = 0; col < arr.GetLength(1) - 0; col++)
arr[row,col] += rnd.Next(rnd_start,rnd_end);
public static void Main(string[] args)
double[,] picture = new double[1000,50];
for (int steps = 0; steps < 100; steps++)
Array_SetValue(picture, 0, 0, 0, 0, 10);
Array_SetValue(picture, 100 + rnd.Next(-rnd_offset,rnd_offset), 100 + rnd.Next(-rnd_offset,rnd_offset), 0, 0, 70);
Array_rnd(picture, -10, 10);
double[,] horz_edge_det_mat = {{1, 1, 1},{0, 0 ,0},{-1, -1, -1}};
double[,] post_picture = new double [picture.GetLength(0) - 2,picture.GetLength(1) - 2];
double sum_edgepicture_col = 0;
double sum_edgepicture = 0;
for (int row = 1; row < (picture.GetLength(0)-1); row++)
for (int col = 1; col < picture.GetLength(1)-1; col++)
for (int row_mat = 0; row_mat < (horz_edge_det_mat.GetLength(0)); row_mat++)
for (int col_mat = 0; col_mat < (horz_edge_det_mat.GetLength(1)); col_mat++)
edge_picture = horz_edge_det_mat[row_mat,col_mat] * picture[(row-1) + row_mat,(col-1) + col_mat];
sum_edgepicture_col += edge_picture;
sum_edgepicture += sum_edgepicture_col;
post_picture[row-1,col-1] = sum_edgepicture;
for (int col = 0; col < post_picture.GetLength(1); col++)
max = post_picture[0,col];
for (int row = 0; row < post_picture.GetLength(0); row++)
if (max < post_picture[row,col])
max = post_picture[row,col];
for (int col = 0; col < post_picture.GetLength(1); col++)
max = post_picture[0,col];
for (int row = 0; row < post_picture.GetLength(0); row++)
if (min > post_picture[row,col])
min = post_picture[row,col];
int current_center = (index_max + index_min) / 2 - 500;
Console.WriteLine(current_center);