Advertisement
szymcio93

Untitled

Nov 4th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. PIERWSZE:
  2. clear all;
  3. close all;
  4. r=pi/6; % kąt obrotu
  5. rot_mtx=[cos(r), -sin(r); sin(r), cos(r)]; % macierz obrotu
  6. T=[50;-20]; % wektor przesunięcia
  7. in = imread( 'checkerBoard_20_200.png' );
  8. in = double( rgb2gray( in ) );
  9. N = size( in, 1 );
  10. [X,Y]=meshgrid( 1:N ); % indeksy pikseli 2D
  11. XY=[ reshape(X,1,N*N); reshape(Y,1,N*N) ];
  12. XYr=rot_mtx*(XY+repmat(T,1,N*N)); % przekształcenie obrazka
  13. Xi=reshape(XYr(1,:),N,N);
  14. Yi=reshape(XYr(2,:),N,N);
  15.  
  16.  
  17.  
  18.  
  19.  
  20. in1=interp2(X,Y,in,Xi,Yi,'nearest');
  21. in2=interp2(X,Y,in,Xi,Yi,'linear');
  22.  
  23. imwrite(in1,'img1.png','png');
  24. imwrite(in2,'img2.png','png');
  25.  
  26. ........................................................................................
  27.  
  28. TRZECIE:
  29. x=X(:,1);
  30. y=X(:,2);
  31. z=X(:,3);
  32.  
  33. [xq,yq]=meshgrid(-5:0.1:15,-10:0.1:10);
  34. V=griddata(x,y,z,xq,yq);
  35.  
  36.  
  37.  
  38.  
  39. hold on
  40.  
  41. surf(V);
  42. hold off
  43.  
  44. -------------------------
  45.  
  46. x = X(:,1);
  47. y = X(:,2);
  48. z = X(:,3);
  49. F = TriScatteredInterp(x,y,z, 'linear');
  50. [qx,qy] = meshgrid(-5:0.2:15, -10:0.2:10);
  51. qz1 = F(qx,qy);
  52. for i=1:length(qz1)
  53. for j=1:length(qz1)
  54. if qz1(i,j) > 55
  55. qz1(i,j) = NaN;
  56. end
  57. end
  58. end
  59.  
  60. qz2=griddata(x,y,z,qx,qy,'cubic');
  61. for i=1:length(qz2)
  62. for j=1:length(qz2)
  63. if qz2(i,j) > 55
  64. qz2(i,j) = NaN;
  65. end
  66. end
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement