I'm just looking for an effective way for the following code, since I get an error, I gave as much information as I can, but maybe you do not need all these explanations, but the code itself is enough, any help will be appreciated to make me go through this an error;
I am trying to apply an operator (HΓΌckel edge detection operator) to a 9x9 area at a time and repeat it for the whole image. Thus, this is a regular definition of the edge of the foundation. You can see what I mean in the second picture.


The a () function is called 8 times in another function called hueckel_operator (), and hueckel_operator is a recursive function that calls itself +5 each time for both x and y parameters. This means that () is called largely for large images and the real problem is MyImage [], which is an emgucv Image <> object. Since MyImage [] must check every pixel in the 9x9 matrix and bring its value, it is called 69 * j times more than the a () function.
The input_i_y () function returns the y coordinate, and there is another function called input_i_x () that brings the x coordinate of the 9x9 matrix. I know it is very difficult to make two separate functions in order to use them as a parameter of another function, but I could not find a better solution. The HueckelDisk class computes the formula of 9 different hueckel drives according to the x, y coordinates. In accordance with the accuracy of the fit, we are sure that there is an edge or not.

here is the termination condition hueckel_operator ()
if (mod_width + counter4 + 10 >= MyImage.Width && mod_height + counter5 + 10 >= MyImage.Height) { goto EXIT2; }
here is the beginning and end of hueckel_operator ()
public void hueckel_operator(int counter2, int counter3) { counter2 = counter4; counter3 = counter5; int mod_width = MyImage.Width % 5; int mod_height = MyImage.Height % 5; if (mod_width + counter4 + 10 >= MyImage.Width && mod_height + counter5 + 10 >= MyImage.Height) { goto EXIT2; } else { if (mod_width + counter4 + 10 >= MyImage.Width) { if (counter5 == 1) { counter5 += 4; } else { counter5 += 5; } counter4 = 1; } if (counter4 == 1) { counter4 += 4; } else if(counter4 != 0) { counter4 += 5; } if (counter5 == 0 && counter4 == 0) { counter4 = 1; counter5 = 1; } }
Here is the end of hueckel_operator ();
EXIT:
hueckel_operator(counter5, counter4); EXIT2: MessageBox.Show("done"); }
there is a function a ()
public double a(int j, int counter6, int counter7) { double result = 0; HueckelDisks hueckel_formula = new HueckelDisks(); counter6 = counter4; counter7 = counter5; for (int II = 0; II <= j ; II++) { for (KK = 1; KK < 69; KK++) { result += hueckel_formula.HueckelDisk(input_i_x(KK),input_i_y(KK),j) * MyImage[point_a, point_b].Intensity; } } return result; } public int input_i_y(int y) { Tuple<int, int>[] myArray = { Tuple.Create(3,1),Tuple.Create(4,1),Tuple.Create(5,1),Tuple.Create(6,1),Tuple.Create(7,1),Tuple.Create(2,2), Tuple.Create(3,2),Tuple.Create(4,2),Tuple.Create(5,2),Tuple.Create(6,2),Tuple.Create(7,2),Tuple.Create(8,2), Tuple.Create(1,3),Tuple.Create(2,3),Tuple.Create(3,3),Tuple.Create(4,3),Tuple.Create(5,3),Tuple.Create(6,3), Tuple.Create(7,3),Tuple.Create(8,3),Tuple.Create(9,3),Tuple.Create(1,4),Tuple.Create(2,4),Tuple.Create(3,4), Tuple.Create(4,4),Tuple.Create(5,4),Tuple.Create(6,4),Tuple.Create(7,4),Tuple.Create(8,4),Tuple.Create(9,4), Tuple.Create(1,5),Tuple.Create(1,5),Tuple.Create(2,5),Tuple.Create(3,5),Tuple.Create(4,5),Tuple.Create(5,5), Tuple.Create(6,5),Tuple.Create(7,5),Tuple.Create(8,5),Tuple.Create(9,5),Tuple.Create(1,6),Tuple.Create(2,6), Tuple.Create(3,6),Tuple.Create(4,6),Tuple.Create(5,6),Tuple.Create(6,6),Tuple.Create(7,6),Tuple.Create(8,6), Tuple.Create(8,6),Tuple.Create(1,7),Tuple.Create(2,7),Tuple.Create(3,7),Tuple.Create(4,7),Tuple.Create(5,7), Tuple.Create(6,7),Tuple.Create(7,7),Tuple.Create(8,7),Tuple.Create(9,7),Tuple.Create(2,8),Tuple.Create(3,8), Tuple.Create(4,8),Tuple.Create(5,8),Tuple.Create(6,8),Tuple.Create(7,8),Tuple.Create(8,8),Tuple.Create(3,9), Tuple.Create(4,9),Tuple.Create(5,9),Tuple.Create(6,9),Tuple.Create(7,9), }; return myArray[y].Item2; }