Advertisement
AbyssTheory

Untitled

Sep 20th, 2014
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.45 KB | None | 0 0
  1. clc; clear all; close all;
  2. %   Set constants (in mm)
  3. %b=315;
  4. %d=450;
  5. b=1000;
  6. d=1000;
  7. deltaw=0.0872664626;
  8.  
  9.  
  10. %   count number of images in imaging folder
  11. c=0;
  12. imgcounter=0;
  13. counter=1;
  14. while c==0
  15.     jpgFileName=strcat('Imaging\images\image', num2str(counter), '.jpg');
  16.     %disp(jpgFileName);
  17.     if exist(jpgFileName, 'file')
  18.         imgcounter=imgcounter+1;
  19.         counter=counter+1;
  20.     else
  21.         c=1;
  22.     end
  23. end
  24.  
  25. %   print number of images
  26. fprintf('There are: %s images \n', num2str(imgcounter));
  27.  
  28.    
  29. depth=0;
  30.  
  31. for l=0:20
  32.     sum=0;
  33.     w=0;  
  34.     totalsum=0;
  35.    
  36.     %   Load Images
  37.     for c = 1:imgcounter
  38.         %   Create an image filename, and read it in to a variable called
  39.         %   imageData.
  40.         jpgFileName = strcat('Imaging\images\image', num2str(c), '.jpg');
  41.         if exist(jpgFileName, 'file')
  42.             imageData = im2double(imread(jpgFileName));
  43.             imageData=rgb2gray(imageData);
  44.             %   Set Dimensions
  45.             [t_r, t_c, trash]=size(imageData);
  46.         end
  47.        
  48.                
  49.         %   Set Columns M(row, columns)= M(j, i)
  50.         for i=1:t_c
  51.             %   Calculate h and r
  52.             %h=(i*d)/(d*cos(w)-i*sin(w));
  53.             h1=i*d
  54.             h2=d*cos(w)-i*sin(w)
  55.             h=h1/h2;
  56.            
  57.             r1=(h-(l*d*sin(w))/(b*cos(w)-l))
  58.             r2=(1-l/(b*cos(w)))
  59.             r=r1*r2;
  60.             rn=round(r);
  61.             %   Test Code
  62.             disp('i has increased');
  63.             disp(i);
  64.             disp(h);
  65.             disp(r);
  66.             disp(c);
  67.             disp(w);
  68.            
  69.             %   Set rows
  70.             for j=1:t_r
  71.                 %   Temporary Code
  72.                 if rn<1 || rn>t_c
  73.                     disp('r is below 1 or > t_c');
  74.                    
  75.                     rn=1;
  76.                 else
  77.                 Mp(j,rn)=imageData(j,i);
  78.                
  79.                 %   Test Code
  80.                 %disp('Rows are running');
  81.                
  82.                 end
  83.                
  84.             end
  85.         end
  86.         imshow(Mp);
  87.         %pause
  88.         sum=sum+Mp;
  89.         %   Set omega +5 degrees
  90.         w=w+deltaw;
  91.         disp(l);
  92.  
  93.     end
  94.    
  95.     %   Calculate M at depth l
  96.     totalsum=sum./imgcounter;
  97.    
  98.     %   Export image at depth l
  99.     str=num2str(depth);
  100.     imwrite(sum, ['Imaging\images\results\' str '.jpeg']);
  101.     depth=depth+1;
  102.     disp('Got to end of l loop');
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement