Matlab to C# conversion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • salma
    New Member
    • Sep 2006
    • 1

    #1

    Matlab to C# conversion

    i m working in image processing in c#,facing problem in converting code from matlab to C#
    %This loops makes a window of 3*3 and scans over the image from left to
    %right and top to bottom to get those pixel values that are most probably
    %a function of Impulse, called Nimp.

    for x=2:1:(sizeM-1)
    for y=2:1:(sizeN-1)
    k = x;
    l = y;
    x1 = f(k-1, l-1); x2 = f(k-1, l); x3 = f(k-1, l+1);
    x4 = f(k, l-1); x5 = f(k, l); x6 = f(k, l+1);
    x7 = f(k+1, l-1); x8 = f(k+1, l); x9 = f(k+1, l+1);
    W = [x1,x2,x3,x4,x5, x6,x7,x8,x9];
    x_sum = 0;
    count = 0;
    x_temp = 0;
    wind(1,1) = W(1);
    wind(1,2) = W(2);
    wind(1,3) = W(3);
    wind(2,1) = W(4);
    wind(2,2) = W(5);
    wind(2,3) = W(6);
    wind(3,1) = W(7);
    wind(3,2) = W(8);
    wind(3,3) = W(9);

    for m=1:1:3
    for n=1:1:3
    x_temp = wind(m,n);
    if((x_temp == min(W)) | (x_temp == max(W)))% | (x_temp <= 10) | (x_temp >= 230))
    Nimp_sub(m, n) = x_temp;
    else
    count = count + 1;
    x_sum = x_sum + x_temp;
    Nimp_sub(m, n) = 0;
    end

    end
    end
    %Nimp=size(f);
    Nimp(k-1:k+1,l-1:l+1) = Nimp_sub;

    counter = counter + 1
    end
    end

    %---------------------------------------------------------------------------
Working...