matlab中的块状图像旋转

时间:2014-02-08 19:27:32

标签: matlab block image-rotation

我正在研究脊线频率估计,我必须获得一个面向块的图像。我已经开发了代码但无法删除错误。

这个过程是这样的。输入图像为G(m,n)theta(m,n)是包含theta的图像。输入图像G分为w*w块(w = 17),对于以pixel(i,j)为中心的每个块,计算大小为l*w (33*17)的定向窗口。对于每个块,我们必须将x签名计算为

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))

这是我的代码

% 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;

错误是

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);

0 个答案:

没有答案