Hi,
I am converting some C++ code to C# now and need some help on reading it!
The C++ code is:
uchar p2 = im.at<uchar>(i-1, j);
uchar p3 = im.at<uchar>(i-1, j+1);
uchar p4 = im.at<uchar>(i, j+1);
uchar p5 = im.at<uchar>(i+1, j+1);
uchar p6 = im.at<uchar>(i+1, j);
uchar p7 = im.at<uchar>(i+1, j-1);
uchar p8 = im.at<uchar>(i, j-1);
uchar p9 = im.at<uchar>(i-1, j-1);
int C = (!p2 & (p3 | p4)) + (!p4 & (p5 | p6)) +
(!p6 & (p7 | p8)) + (!p8 & (p9 | p2));
int N1 = (p9 | p2) + (p3 | p4) + (p5 | p6) + (p7 | p8);
int N2 = (p2 | p3) + (p4 | p5) + (p6 | p7) + (p8 | p9);
int N = N1 < N2 ? N1 : N2;
int m = iter == 0 ? ((p6 | p7 | !p9) & p8) : ((p2 | p3 | !p5) & p4);
And the C# code I have written so far is:
int i2 = ( i - 1 ) * widthStep + ( j );
int i3 = ( i - 1 ) * widthStep + ( j + 1 );
int i4 = ( i ) * widthStep + ( j + 1);
int i5 = ( i + 1 ) * widthStep + ( j + 1 );
int i6 = ( i + 1) * widthStep + ( j );
int i7 = ( i + 1) * widthStep + ( j - 1);
int i8 = ( i ) * widthStep + ( j - 1 );
int i9 = ( i - 1) * widthStep + ( j - 1 );
byte p2 = imagePtr[ i2 ];
byte p3 = imagePtr[ i3 ];
byte p4 = imagePtr[ i4 ];
byte p5 = imagePtr[ i5 ];
byte p6 = imagePtr[ i6 ];
byte p7 = imagePtr[ i7 ];
byte p8 = imagePtr[ i8 ];
byte p9 = imagePtr[ i9 ];
int C = ??
int N1 = ??
int N2 = ??
int N = //I can do this
int m = ??
Can someone please tell me how I build C, N1, N2 and m?