Retinal Model: Static Eye, X Cells, Different Spatial Scales, Color test

This is a model of the retina.  The current assumptions are that the eye is perfectly still and that the x cells, the only current cells modeled, can be characterized by DOG functions.  The output will be generated at 4 spatial scales, in order, automatically, with each successive scale with a peak spatial frequency at 1/2 of the previous cell array (that is, 1 octive lower).

To start using this model, input any 8bit bitmapped image.  The size is limited by the power of your computer and your patience in waiting for output.  Give the path for the image.  But first load this matrix manipulation function.

<< LinearAlgebra`MatrixManipulation`

Input Your image

inpic = 
        Import["c:\Documents and Settings\John H. Krantz\My \
Documents\Classes\Culminating/2002-2003\Blythe\blue-gold.bmp"];
retarray = inpic[[1, 1] ]; 
    Print["Dimensions of Input Array ",  Dimensions[retarray]]; 
    bigdim = Dimensions[retarray];

Show[inpic];

Print[Max[retarray]]
Print[Min[retarray]]

Set the baseline parameter for the ganglion cell

se  =  2; si = 6;

Create the Color conversion Matrix

rgbToTriStim =  (({{0.607, 0.174, 0.2000}, {0.299, 0.587, 0.114}, {0.00, 0.066, 1.116}}));triStimToLMS =(({{0.61209, 2.14231, -0.12966}, {-0.969775, 2.855775, 0.205425}, {0, 0, 1.21183}}));LMSToATD = (({{0.85, 1.50, 0.01}, {1.66, -2.43, .0}, {-0.34, -0.26, +0.71}}));RGBToLMS  =  rgbToTriStim . triStimToLMS;triStimToATD = triStimToLMS . LMSToATD;RGBToATD = RGBToLMS . LMSToATD;CIEchart=(({{400, 0.0143, 0.0004, 0.0679}, {410, 0.0435, 0.0012, 0.2074}, {420, 0.1344, 0.0040, 0.6456}, {430, 0.2839, 0.0116, 1.3856}, {440, 0.3483, 0.0230, 1.7471}, {450, 0.3362, 0.0380, 1.7721}, {460, 0.2908, 0.0600, 1.6692}, {470, 0.1954, 0.0910, 1.2876}, {480, 0.0956, 0.1390, 0.8130}, {490, 0.0320, 0.2080, 0.4652}, {500, 0.0049, 0.3230, 0.2720}, {510, 0.0093, 0.5030, 0.1582}, {520, 0.0633, 0.7100, 0.0782}, {530, 0.1655, 0.8620, 0.0422}, {540, 0.2904, 0.9540, 0.0203}, {550, 0.4334, 0.9950, 0.0087}, {560, 0.5945, 0.9950, 0.0039}, {570, 0.7621, 0.9520, 0.0021}, {580, 0.9163, 0.8700, 0.0017}, {590, 1.0263, 0.7570, 0.0011}, {600, 1.0622, 0.6310, 0.0008}, {610, 1.0026, 0.5030, 0.0003}, {620, 0.8544, 0.3810, 0.0002}, {630, 0.6424, 0.2650, 0.0000}, {640, 0.4479, 0.1750, 0.0000}, {650, 0.2835, 0.1070, 0.0000}, {660, 0.1649, 0.0610, 0.0000}, {670, 0.0874, 0.0320, 0.0000}, {680, 0.0468, 0.0170, 0.0000}, {690, 0.0227, 0.0082, 0.0000}, {700, 0.0114, 0.0041, 0.0000}}));CIEout =  Table[0, {i, 31}, {j, 4}];

Create An Image

Convert Input Array into color opponent RG BY BlackWhite channel

Array BlackWhite BY channel color Convert Input into opponent RG

Run the model and go get lunch.

First separarate out the channel to processes from the complex array.  That is the command after the printing for the channel

opponentChannels = retarray;
\(Do[Do[
        temp3 = rgbToTriStim . {retarray[\([x, y, 1]\)], 
                retarray[\([x, y, 2]\)], retarray[\([x, y, 3]\)]} // 
            VectorForm; 
        temp2 = triStimToLMS . {temp3[\([1, 1]\)], temp3[\([1, 2]\)], 
                temp3[\([1, 3]\)]} // VectorForm; 
        temp = LMSToATD . {temp2[\([1, 1]\)], temp2[\([1, 2]\)], 
                temp2[\([1, 3]\)]} // VectorForm; 
        opponentChannels[\([x, y, 1]\)] = temp[\([1, 1]\)]; 
        opponentChannels[\([x, y, 2]\)] = temp[\([1, 2]\)]; 
        opponentChannels[\([x, y, 3]\)] = temp[\([1, 3]\)], {x, 
          bigdim[\([1]\)]}], {y, bigdim[\([2]\)]}]; 
    Do[Print["Output for Channel ", channel]; 
      chanArray = \ opponentChannels[\([All, All, channel]\)]; 
      Do[ses\  = \ se*2\^\((st - 1)\); sis = si*2\^\((st - 1)\); 
        width = 3*sis; 
        ganglion = 
          Table[\(\((sis/ses)\)\/\(\((ses)\)*\@\(2*Pi\)\)\) 
                  Exp[\(-\(\((\((i - width)\)\^2 + \((j - width)\)\^2)\)\/\((2*ses\^2)\)\)\)] - \(1\/\(\((sis)\)*\@\(2*Pi\)\)\) 
                  Exp[\(-\(\((\((i - width)\)\^2 + \((j - width)\)\^2)\)\/\((2*\((sis)\)\^2)\)\)\)] // N, {i, 2*width + 1}, {j, 
              2*width + 1}]; 
        upi = IntegerPart[\((bigdim[\([1]\)] - \((2*width + 1)\))\)/5]; 
        upj = IntegerPart[\((bigdim[\([2]\)] - \((2*width + 1)\))\)/5]; 
        Q = \((1/\((width)\))\); 
        If[st == 1, 
          If[channel == 1, Print["Make output Array for scale ", st]; 
            scale1Out = Table[0, {x, 3}, {y, upi}, {z, upj}];]]; 
        If[st == 2, 
          If[channel == 1, Print["Make output Array for scale ", st]; 
            scale2Out = Table[0, {x, 3}, {y, upi}, {z, upj}];]]; 
        If[st == 3, 
          If[channel == 1, Print["Make output Array for scale ", st]; 
            scale3Out = 
              Table[0, {x, 3}, {y, upi}, {z, 
                  upj}];]]; 
OutputArray = 
          Table[Q*Apply[Plus, 
                Apply[Plus, 
                  ganglion*
                    SubMatrix[
                      chanArray, {\((i - 1)\)*5 + 1, \((j - 1)\)*5 + 
                          1}, {2*width + 1, 2*width + 1}]]], {i, 1, upi}, {j, 
              1, upj}]; 
        If[st == 1, scale1 = OutputArray; 
          Do[Do[scale1Out[\([channel, x, y]\)] = scale1[\([x, y]\)], {x, 1, 
                upi}], {y, 1, upj}];, 
          If[st == 2, scale2 = OutputArray; 
            Do[Do[scale2Out[\([channel, x, y]\)] = scale2[\([x, y]\)], {x, 1, 
                  upi}], {y, 1, upj}];, scale3 = OutputArray; 
            Do[Do[scale3Out[\([channel, x, y]\)] = scale3[\([x, y]\)], {x, 1, 
                  upi}], {y, 1, 
                upj}];]]; 
Print["Output of the Retina at Excitatory SD ", ses, " and Inhibitory SD ", sis]; 
        Print["Maximun Value = ", 
          Max[OutputArray], " Minimum Value = ", Min[OutputArray]]; 
        Show[GraphicsArray[{SurfaceGraphics[OutputArray, \ 
                Lighting -> False, PlotRange -> {\(-300\), 300}], 
              SurfaceGraphics[OutputArray, 
                ViewPoint\  -> \ {0, 0, 1000}, Mesh -> False, 
                Lighting -> False, 
                PlotRange -> {\(-300\), 300}]}]];, {st, 2}];, {channel, 
        3}];\)