Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. %2a
  2. syms x y sigma
  3. h = exp(-(x.^2 + y.^2)/(2*sigma^2))/(2*pi*sigma^2);
  4. h_y = diff(h,y,1)% first diffentiate of h with respect to y
  5. %2b
  6. sigma= 1.5;
  7. delta = 1;
  8. sigma = sigma.*delta;
  9. L = 2*ceil(sigma*4)+1; % fill in a constant to define the matrix size
  10. xymax = (L-1)/2; % the maximum of the x and the y coordinate
  11. xrange = -xymax:xymax; % the range of x values
  12. yrange = xrange; % the range of y values
  13. figure(3)
  14. N = (L-1)/2; % get the size of half of the full range
  15. [x,y]=meshgrid(-N:N,-N:N); % create the coordinates of a 2D orthogonal grid
  16. hy = -(y.*exp(-(x.^2 + y.^2)/(2*sigma^2)))/(2*sigma^4*pi)
  17. C = cat(3, ones(size(hy)),ones(size(hy)),zeros(size(hy)));
  18. % create a RGB matrix to define the colour of the surface plot
  19. hd =surf(xrange,yrange,hy,C,'FaceColor','interp','Facelight','phong');
  20. % % create the surface plot of the gaussian
  21. camlight right % add a light at the right side of the scene
  22. xlim([-xymax xymax]); % set appropriate axis limits
  23. ylim([-xymax xymax]);
  24. xlabel('x'); % add axis labels
  25. ylabel('y');
  26. zlabel('hy(x,y)');
  27. print -r150 -dpng ex3_2b.png % print the result to file
  28. imfiltered_hy = imfilter(im,hy) ; % apply the filter
  29. imfiltered_hy = mat2gray(imfiltered_hy);
  30. figure(4);imshow(imfiltered_hy,[]);
  31. imwrite(imfiltered_hy, 'Imfiltered_hy_Ex3_Q2b.jpg')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement