function [normals kd]= solve_normals(dir, l)

file_count = 12;


mask = imread(sprintf('psmImages/%s/%s.mask.tga.ppm', dir, dir));
img0 = imread(sprintf('psmImages/%s/%s.0.tga.ppm', dir, dir));
data=rgb2gray(img0);

for i=1:11
    img = imread(sprintf('psmImages/%s/%s.%d.tga.ppm', dir, dir, i));
    gray_scale=rgb2gray(img);
    data = cat(3, data, gray_scale);
	size(data);
end

normals = zeros(size(data,1), size(data,2), 3);

for r=1:size(data,1)
    for c=1:size(data,2)
        inten = data(r,c,:);
        n=l\double(inten(:));
        normals(r,c,1:3) = n / norm(n);
        if isnan(normals(r,c,:)) 
            normals(r,c,:)=0;
        end
        
        kd(r,c)=norm(n);
    end
end

%normals = normals(:,:,1:3);
