-
Notifications
You must be signed in to change notification settings - Fork 2
/
FGr.m
33 lines (26 loc) · 1.03 KB
/
FGr.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function RM = FGr(im)
% compute the RO RM and GM map
% Detailed explanation goes here
sigma = 0.5;
[im_Dx,im_Dy] = gaussian_derivative(im,sigma);% compute the basic gradient maps in the horizontal x and vertical y directions
aveKernel = fspecial('average', 3);
eim_Dx = conv2(im_Dx, aveKernel,'same');
eim_Dy = conv2(im_Dy, aveKernel,'same');% compute the average directional derivative
im_D=atan(eim_Dx./(eim_Dy));
%im_D(eim_Dy==0)=pi/2;
%
%RO=atan(im_Dx./(im_Dy));
%RO(im_Dy==0)=pi/2;
%RO=RO-im_D; % compute RO
%
%GM=sqrt(im_Dx.^2+im_Dy.^2); % compute GM
RM=sqrt((im_Dx-eim_Dx).^2+(im_Dy-eim_Dy).^2); %compute RM
end
function [gx,gy] = gaussian_derivative(imd,sigma) % comput the gaussian derivative
window1 = fspecial('gaussian',2*ceil(3*sigma)+1+2, sigma);
winx = window1(2:end-1,2:end-1)-window1(2:end-1,3:end);winx = winx/sum(abs(winx(:)));
% winy = window1(2:end-1,2:end-1)-window1(3:end,2:end-1);winy = winy/sum(abs(winy(:)));
winy=winx';
gx = filter2(winx,imd,'valid');
gy = filter2(winy,imd,'valid');
end