All pastes #202683 Raw Edit

Miscellany

public text v1 · immutable
#202683 ·published 2006-10-14 17:59 UTC
rendered paste body
function [F1real, F2real] = noisy_faces_hebb ()

%

F1 = rgb2gray (imread ('Cam.jpg'));
F2 = rgb2gray (imread ('DaveC.jpg'));

% bring to a single dimension
t1 = double (reshape (F1, 1, []));
t2 = double (reshape (F2, 1, []));

% normalize
p1 = create_noise (t1, 0.05) / norm (t1); % noise test
p2 = t2 / norm (t2);

% build full T and P matrices
T = cat (2, t1, t2);
P = cat (2, p1, p2);

W = T * P';

p1real = W * p1;
p2real = W * p2;

% adjust the contrast of the image
constant = norm (cat (1, p1real, p2real)) / norm (cat (1, t1, t2));

p1real = p1real / constant;
p2real = p2real / constant;

F1real = uint8 (reshape (p1real, 27, []));
F2real = uint8 (reshape (p2real, 27, []));

p1error = p1real - t1;
p2error = p2real - t2;

error1 = sum (abs (p1error (:))) / numel (p1error)
error2 = sum (abs (p2error (:))) / numel (p2error)

imshow (F1real);