% b je bitmapa
b = imread('vstup.bmp');
[s,s1,u] = size(b);
x = double(reshape(b,s*s1,3))'/256;

% trénovací vzory "navíc"
pom = repmat([1,0,0],s*s1,1)';
%pom = repmat([1,0,1],10000,1)';

p = x;
p = [p pom];
% náhodnì uspoøádám vzory
P=randperm(size(p,2));
p = p(:,P); 
t = p;

% Vytvoøím neuronovou sí�
net = newff(p,t,[5],{'logsig','logsig'},'trainscg');

net.outputs{2}.processFcns = {};
net.inputs{1}.processFcns = {};

net.trainParam.epochs = 100;
net.trainParam.max_fail = 10;
net.trainParam.Goal = 0.0001;
%net.divideFcn ='';
net.trainParam.showWindow=0;

% Nauèím neuronovou sí�
[net1,tr] = train(net,p,t);

% Výstup (odezva) sítì
y = sim(net1,x);

b2 = uint8(reshape(y'*256,s,s1,u));

imwrite(b2,'vystupB.bmp');

