function img=diffuse(img,tf,dtime,outName)
%
% CNN diffuse template applied to image file.
% 
% Usage: img=diffuse(img, tf, dtime);
%


% control/feedforward (B) and feedback (A) templates -- tunable
A = [0.1 0.15 0.1;0.15 0 0.15;0.1 0.15 0.1]
B = zeros(3,3)

u = im2double(img);
uu = im2double(max(max(u)));
ul = im2double(min(min(u)));
%[uy,ux] = size(u);
u = (u-ul)/(uu-ul)*2-1;
%x0 = -1*ones(uy,ux);
x0 = u;

I = 0 ;

state=viewcnn(A,B,I,x0,u,tf,dtime);
img=pwlsig(state);
%img=state+u+1;
%imwrite(img,outName,'tiff');
%figure;imagesc(img);colormap(gray);



