Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Matlab to C# conversion

Matlab to C# conversion

Scheduled Pinned Locked Moved C#
csharphelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    signimage
    wrote on last edited by
    #1

    i am sending matlab code,can some one help me to convert this code into C#, imagex=imread('D:\MS_courses\ece655\Project\test_images\test_image3.jpg'); %RGB2GRAY converts RGB images to grayscale by eliminating the %hue and saturation information while retaining the luminance. %im2double takes an image as input, and returns an image of class double. f = im2double(rgb2gray(imagex)); %f=[.1,.2,.3;.4,.5,.6;.7,.8,.9]; %Storing the number of rows and columns in separate output variables [sizeM, sizeN] = size(f); %Counter is used just to check the status of the program at all times. counter = 0; %for k=1:1:256 %gvalue_f(k) = 0; %gvalue_N(k) = 0; %end %-------------------------------------------------------------------------- %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 %for k=2:1:sizeM-1 % for k=2:1:sizeN-1 % gvalue_f(f(k, l)) = gvalue_f(f(k, l)) + 1; % Nimp_db = im2uint8(Nimp(k, l)) + 1; % gvalue_N(Nimp_db(k, l)) = gvalue_N(Nimp_db(k, l)) + 1; %end %end %Calculating the histograms of input image and Nimp (those pixels in the image %which are most probably members of impulse noise). temp_hist_f = hist(f, 256); temp_hist_imp = hist(N

    K 1 Reply Last reply
    0
    • S signimage

      i am sending matlab code,can some one help me to convert this code into C#, imagex=imread('D:\MS_courses\ece655\Project\test_images\test_image3.jpg'); %RGB2GRAY converts RGB images to grayscale by eliminating the %hue and saturation information while retaining the luminance. %im2double takes an image as input, and returns an image of class double. f = im2double(rgb2gray(imagex)); %f=[.1,.2,.3;.4,.5,.6;.7,.8,.9]; %Storing the number of rows and columns in separate output variables [sizeM, sizeN] = size(f); %Counter is used just to check the status of the program at all times. counter = 0; %for k=1:1:256 %gvalue_f(k) = 0; %gvalue_N(k) = 0; %end %-------------------------------------------------------------------------- %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 %for k=2:1:sizeM-1 % for k=2:1:sizeN-1 % gvalue_f(f(k, l)) = gvalue_f(f(k, l)) + 1; % Nimp_db = im2uint8(Nimp(k, l)) + 1; % gvalue_N(Nimp_db(k, l)) = gvalue_N(Nimp_db(k, l)) + 1; %end %end %Calculating the histograms of input image and Nimp (those pixels in the image %which are most probably members of impulse noise). temp_hist_f = hist(f, 256); temp_hist_imp = hist(N

      K Offline
      K Offline
      Kim0618
      wrote on last edited by
      #2

      I dont think there are someone being kind enough to convert the code for you as the task will take about 1 to a few days. Instead you may learn C# (easy to pick up) and diy :)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups