550 likes | 705 Views
Biologically Inspired Intelligent Systems. Lecture 06 Dr. Roger S. Gaborski. Correlation (Convolution). Simple example. >> data = [.1 .1 .1 .1 .1 .1 .1 .5 .1 .1 .1 .5 1 .5 .1 .1 .1 .1 .1]; >> RF = [ -1 -1 1 2 1 -1 -1];. = -1*0 +-1*0 + 1*0 + 2*.1 + 1* .1 -1*.1 -1*.1 = .1 .
E N D
Biologically Inspired Intelligent Systems Lecture 06 Dr. Roger S. Gaborski Roger S. Gaborski
Correlation (Convolution) • Simple example >> data = [.1 .1 .1 .1 .1 .1 .1 .5 .1 .1 .1 .5 1 .5 .1 .1 .1 .1 .1]; >> RF = [ -1 -1 1 2 1 -1 -1]; = -1*0 +-1*0 + 1*0 + 2*.1 + 1* .1 -1*.1 -1*.1 = .1 Roger S. Gaborski
Correlation (Convolution) • Simple example >> data = [.1 .1 .1 .1 .1 .1 .1 .5 .1 .1 .1 .5 1 .5 .1 .1 .1 .1 .1]; >> RF = [ -1 -1 1 2 1 -1 -1]; = -1*0 + -1*0 + 1*.1 + 2*.1 + 1*.1 +-1*1 = .2 Roger S. Gaborski
Matlab >> data = [.1 .1 .1 .1 .1 .1 .1 .5 .1 .1 .1 .5 1 .5 .1 .1 .1 .1 .1]; >> RF = [ -1 -1 1 2 1 -1 -1]; >> res = imfilter(data,RF) res = Columns 1 through 8 0.1000 0.2000 0.1000 0 -0.4000 -0.4000 0.4000 0.8000 Columns 9 through 16 0 -1.7000 -1.3000 1.3000 2.6000 1.3000 -0.9000 -1.3000 Columns 17 through 19 -0.3000 0.2000 0.1000 Roger S. Gaborski
Plot of data figure, stem(data, 'r') axis([0,20,-3 3]) Roger S. Gaborski
1D RF Roger S. Gaborski
RED – input data BLUE – RF response Roger S. Gaborski
A simple 1D RF • First, Recall from lecture 05, 128x128 RF applied to gray scale Flag image Roger S. Gaborski
NONLINEAR RESPONSE About 40 pixels NLcon128 = double(imContrast128>0) .* imContrast128; figure, imshow(Con128, [ ]), title('Nonlinear imContrast128’) colorbar Roger S. Gaborski
Closer Inspection Roger S. Gaborski
Original gray scale pixel values Roger S. Gaborski
1D RF 128 Roger S. Gaborski
Partial Match Roger S. Gaborski
Strong Match Roger S. Gaborski
Strong Mismatch Roger S. Gaborski
figure, plot(Con128(98,:)) RF Response Roger S. Gaborski
In Class Exercise - Correlation Roger S. Gaborski
GOAL: Biologically Inspired Vision System • Extract low level features using biologically inspired feature detectors (receptive fields) • Implement a Focus of Attention (FOA) mechanism based on low level features • Modify the low level FOA with high level information • Extract complex features in regions of FOA • Perform classification on objects in FOA area Roger S. Gaborski
Low Level Feature Extraction -1 • Form Contrast Image by convolving gray level input image with a set of Difference of Gaussian filters which model center on and center off circular receptive fields in retina • For Example: • Sizes 8x8, 16x16 and 32x32pixels • Small object will respond strongly to 8x8 DoG, large objects will respond strongly to 32x32 DoG Roger S. Gaborski
Vision Model of Retinal Processing Contrast Images imConv8 imConv16 imConv32 Retina Model 8x8, 16x16 and 32x32 circular receptive fields Gray Level Image Roger S. Gaborski
Low Level Feature Extraction -2 • Convolve Contrast Image*images with Gabor modeled directional receptive fields • 0, 45, 90 and 135 degrees • Size: 7x7, 15x15 and 31x31 • Rectify resulting image (absolute value) • Know as S1 Cells Roger S. Gaborski
Vision Model of Visual Cortex Modeling – Simple Cells S1 WHERE n = 0, 45, 90 and 135 degrees n degrees 7x7 Gabor n degrees 15x15 Gabor n degrees 31x31 Gabor n degrees 7x7 Gabor n degrees 15x15 Gabor n degrees 31x31 Gabor n degrees 7x7 Gabor n degrees 15x15 Gabor n degrees 15x15 Gabor Contrast Images imConv8 imConv16 imConv32 (Retina Model) Retina Model 8x8, 16x16 and 32x32 circular receptive fields Gray Level Image Roger S. Gaborski
Summary:Simple Cell Directional Images • Three contrast images (Retinal Model) • DoG8, DoG16 and DoG32 • Four Orientation Receptive Fields (Simple Visual Cortex Processing) • 0, 45, 90 and 135 degrees • Three sizes for each RF • 7x7, 15x15 and 31x31 3x4x3 = 36 Simple Cell images Roger S. Gaborski
Orientation Sensitivity You can quantify a neuron’s response in terms of its firing rate, the number of action potentials that occur per unit of time The response of the cell depends on the location and orientation Of the stimulus pattern Roger S. Gaborski
Directional Receptive Fieldsare Modeled with Gabor FunctionsCosine Grating * 2D Gaussian Roger S. Gaborski
Edge Direction and Gradients Edge 90 Degrees 0 1.0 Gradient: 0 degrees Roger S. Gaborski
Cosine Grating and Slice Edge Direction 90 degrees 0 Degrees Cosine Grating Slice Indicated by Blue Bar Roger S. Gaborski
45 Degrees Cosine Grating Edge Direction 135 degrees Roger S. Gaborski
GratingOrientation – Gradient Orientation function [im_cosim_sin] = MakeGrating2( orient, numOfSamples, numOfCycles) %parameters: 0,10,2 %numOfSamples = 10 willgenerate a 63x63 im_sin, im_cos %GradientOrientation - Notedgeorientation %orient = 2*pi - (orient*pi/180); orient = (orient*pi/180); % CONVERT TO RADIANS %creategrading step = 1/numOfSamples; [x,y] = meshgrid( -pi:step:pi, -pi:step:pi); %SIZE OF x IS 63x63, same for y ramp = (cos (orient) * x) - (sin(orient)*y); %sin fcnparameteris in radians figure, imagesc(ramp), colormap(gray) im_sin = sin(ramp*numOfCycles); im_cos = cos(ramp*numOfCycles); figure, imagesc(im_cos), colormap(gray), title('Cos Grating') figure, imagesc(im_sin), colormap(gray), title('Sin Grating') Roger S. Gaborski
Ramp Roger S. Gaborski
ramp*numOfCycles numOfCycles = 2 NOTE change in range Roger S. Gaborski
im_sin = sin(ramp*numOfCycles); Roger S. Gaborski
im_cos = cos(ramp*numOfCycles); Roger S. Gaborski
To obtain the Gabor function we need to multiply the grating by a 2D Gaussian Roger S. Gaborski
Gaussian and Gabor %Generate Gaussian [grat_cos, grat_sin ] = MakeGrating2(45,10,2); filtSize = min(size(grat_cos)); x = linspace(-1,1,filtSize)*filtSize/2; sd = 12; y = (1/sqrt(2*pi*sd)).*exp(-.5*((x/sd).^2)); filt = (y'*y);filt=filt./max(filt(:)); %Gaussian figure, imagesc(filt), title('filt') colormap(hot) Roger S. Gaborski
%Generate Gabor Gabor_sin = grat_sin .* filt; %Gratingmultipied by 2D Gaussian figure, imagesc(Gabor_sin), axis square, colorbar title('Gabor\_sin') Gabor_cos = grat_cos .* filt; figure, imagesc( Gabor_cos), axis square title('Gabor\_cos') Gabor_cos0_63 = Gabor_cos; Gabor_cos0_31 = imresize(Gabor_cos,[31 31], 'bicubic'); Gabor_cos0_15 = imresize(Gabor_cos,[15 15], 'bicubic'); Gabor_cos0_7 = imresize(Gabor_cos,[7 7], 'bicubic'); Roger S. Gaborski
90 Degree Gradient Roger S. Gaborski
90 Degree Gradient Roger S. Gaborski
90 Degree Gradient will strongly respond to bars at 0 degrees Roger S. Gaborski
Multiply 2D Grating by 2D Gaussian Roger S. Gaborski
Gabor Models of Directional Receptive Fields: Gradient Directions 135 degrees 90 degrees 45 degrees 0 degrees Roger S. Gaborski
Receptive Fields measure in the cat Roger S. Gaborski
63x63 Roger S. Gaborski
31x31 Roger S. Gaborski
15x15 Roger S. Gaborski
7x7 Roger S. Gaborski
Process Image with RFCorrelation approach (no rotation of RF) Roger S. Gaborski
Pattern One Image Roger S. Gaborski