function [R, D, G, l, c, N] = matrice_R_G(J,a,color) 

close all;

figure, imshow(J);

ed = @edginess;
cons = @byaverage;
n = @norme;
gradient = @grad;
J = imread(J);
imwrite(J,'moi.tif');
N = im2double(J);
if a == 1
    N = wiener2(N,[3 3]);
elseif a == 2
    N = histeq(N);
end
[l,c] = size(N);
R = [];
for i = 1:l-1
    for j = 1:c-1
        e(i,j) = feval( ed, N, i, j);
        d(i,j) = feval( cons, N ,i, j);
        g(i,j) = feval( gradient, N, i, j, 1);
        D(i,j) = d(i,j);
        R(i,j) = e(i,j)*d(i,j);
        G(i,j) = e(i,j)*d(i,j)*g(i,j);
    end     
end




    
