Reputation: 256
I am working on ridge frequency estimation for which I have to obtain an blockwise oriented image. I have developed the code but unable to remove an error.
the process goes like this. Input image is G(m,n)
and theta(m,n)
is an image containing theta. Input image G
is divide into w*w
block (w = 17
) and for each block centred at pixel(i,j)
compute an oriented window of size l*w (33*17)
. For each block we have to compute the x
signature as
x[0],x[1],x[2].....x[l-1]...
x[k] = 1/w * summation(d=0 to w-1)G(u,v)
u = i+ (d-(w/2))cos(theta(i,j))+(k-(l/2))sin(theta(i,j))
v = i+ (d-(w/2))sin(theta(i,j))+((l/2)-k)cos(theta(i,j))
here is my code
% To compute ridge frequency
theta_image; theta image as input
im = imread('cameraman.tif');
[m,n] = size(im);
l = (2*w-1);
w = 17;
ww = floor(w/2);
for i1 = 9:w:m
for j1 = 9:w:n
G = im(i1-ww:i1+ww,j1-ww:j1+ww);
O = theta(i1-ww:i1+ww,j1-ww:j1+ww);
G = padarray(G,[10 10],'both'); not sure its correct?
for k = 0:l-1
for d = 0:w-1
cnst_1 = (d-floor(w/2));
cnst_2 = (k-floor(l/2));
cnst_3 = (floor((l/2)-k);
u = i1+(cnst_1.*cos(O(i1,j1)) + cnst_2.*sin(O(i1,j1)));
v = j1+(cnst_1.*sin(O(i1,j1)) + cnst_3.*cos(O(i1,j1)));
u = fix(u);
v = fix(v);
store(k,d) = G(u,v);
x(k) = (sum(G(u,v)))/w; not sure will it be stored block-wise?
end;
end;
end;
end;
the error is
Attempted to access G(22,0); index must be a positive integer or logical.
Error in ridge_frequency (line 76)
store(k,d) = G(u,v);
Upvotes: 0
Views: 207