function [im_on, im_off] = retina(im0, wsize, S) K = 3; h = fspecial('gaussian', wsize, S) - fspecial('gaussian', wsize, K*S); [ny, nx, nc] = size(im0); h = wsize*h /norm(h); %h = [[0 -0.25 0]; [-0.25 1 -0.25]; [0 -0.25 0]; ]; im_on = imfilter(im0, h, 'replicate'); im_on = im_on/max(reshape(im_on, 1, nx*ny)); %im_on = min(1, max(0, im_on)); im_off = imfilter(1-im0, h, 'replicate'); im_off = im_off/max(reshape(im_off, 1, nx*ny)); %im_off = min(1, max(0, im_off));