function [K, L, A, W] = ed_ica(fn, c, d)

I = imread(fn);
[p,q] = size(I);

J = [];
cc = c - 1;
dd = d - 1;
pq = (p-cc)*(q-dd);

for i=0:cc
    for j=0:dd
 %       if (i==1&j==1) 
 %       else 
            J = [J; reshape(I(1+i:p-cc+i, 1+j:q-dd+j), 1, pq)];
 %       end
    end
end

[icasig, A, W] = fastica(J);

ij = size(icasig, 1);

pivot = int8((d-1)/2)*c + int8((c+1)/2);
[A1, icasig1] = remove_largest(A, icasig);

K = A1(pivot,:)*icasig1;
%K = A(pivot,1:ij-1)*icasig(1:ij-1,:);

show_vector2(K, p-cc, q-dd);

L = A1*icasig1;
%L = A(:,1:ij-1)*icasig(1:ij-1,:);
