Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %2a
- syms x y sigma
- h = exp(-(x.^2 + y.^2)/(2*sigma^2))/(2*pi*sigma^2);
- h_y = diff(h,y,1)% first diffentiate of h with respect to y
- %2b
- sigma= 1.5;
- delta = 1;
- sigma = sigma.*delta;
- L = 2*ceil(sigma*4)+1; % fill in a constant to define the matrix size
- xymax = (L-1)/2; % the maximum of the x and the y coordinate
- xrange = -xymax:xymax; % the range of x values
- yrange = xrange; % the range of y values
- figure(3)
- N = (L-1)/2; % get the size of half of the full range
- [x,y]=meshgrid(-N:N,-N:N); % create the coordinates of a 2D orthogonal grid
- hy = -(y.*exp(-(x.^2 + y.^2)/(2*sigma^2)))/(2*sigma^4*pi)
- C = cat(3, ones(size(hy)),ones(size(hy)),zeros(size(hy)));
- % create a RGB matrix to define the colour of the surface plot
- hd =surf(xrange,yrange,hy,C,'FaceColor','interp','Facelight','phong');
- % % create the surface plot of the gaussian
- camlight right % add a light at the right side of the scene
- xlim([-xymax xymax]); % set appropriate axis limits
- ylim([-xymax xymax]);
- xlabel('x'); % add axis labels
- ylabel('y');
- zlabel('hy(x,y)');
- print -r150 -dpng ex3_2b.png % print the result to file
- imfiltered_hy = imfilter(im,hy) ; % apply the filter
- imfiltered_hy = mat2gray(imfiltered_hy);
- figure(4);imshow(imfiltered_hy,[]);
- imwrite(imfiltered_hy, 'Imfiltered_hy_Ex3_Q2b.jpg')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement