function [orientim, reliability] = ... ridgeorient(im, gradientsigma, blocksigma, orientsmoothsigma) [rows,cols] = size(im); % Calculate image gradients.
sze = fix(6*gradientsigma); if ~mod(sze,2); sze = sze+1; end f = fspecial('gaussian', sze, gradientsigma); % Generate Gaussian filter.
[x,y] = gradient(f); % Gradient of Gausian.
[fx,fy]=meshgrid(x,y); Gx = filter1(fx, im); % Gradient of the image in x
Gy = filter1(fy, im); % ... and y
%Gx=imfilter(im,fx,'conv','replicate');
%Gy=imfilter(im,fy,'conv','replicate');
% Estimate the local ridge orientation at each point by finding the
% principal axis of variation in the image gradients.
Gxx = Gx.^2; % Covariance data for the image gradients
Gxy = Gx.*Gy; Gyy = Gy.^2; % Now smooth the covariance data to perform a weighted summation of the
% data.
sze = fix(6*blocksigma); if ~mod(sze,2); sze = sze+1; end f = fspecial('gaussian', sze, blocksigma); Gxx = filter2(f, Gxx); Gxy = 2*filter2(f, Gxy); Gyy = filter2(f, Gyy); % Analytic solution of principal direction
denom = sqrt(Gxy.^2 + (Gxx - Gyy).^2) + eps; sin2theta = Gxy./denom; % Sine and cosine of doubled angles
cos2theta = (Gxx-Gyy)./denom; sze = fix(6*orientsmoothsigma); if ~mod(sze,2); sze = sze+1; end f = fspecial('gaussian', sze, orientsmoothsigma); cos2theta = filter2(f, cos2theta); % Smoothed sine and cosine of
sin2theta = filter2(f, sin2theta); % doubled angles
orientim = pi/2 + atan2(sin2theta,cos2theta)/2;
??? Undefined function or method 'conv2' for input arguments of type 'double' and attributes 'full 3d real'.
Error in ==> filter2 at 73 y = conv2(hcol, hrow, x, shape);
Error in ==> ridgeorient at 56 Gxx = filter2(f, Gxx);
Best Answer