You are on page 1of 5

AI and human Cognition - Assignment1

Mads Andersen - s204137


March 2021

Question 1 - Lateral inhibition


We are asked to use the given functions to simulate the activation’s of the photo receptors when they are stimulated
by light. We use the following input: [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]

What are the activation levels of the cells and which has the highest activation levels?
We implement the formula in the python file:
Ai = Ii − w(Ii−1 + Ii+1 ) f or i = 2, ..N − 1
The formula calculates the activation level, by multiplying the sum of the neighbouring cells with a given constant
weight(w) which is has the value w = 0.1. We then subtract this product from the input value (Ii ). When the input
has been calculated, we get the following output:
A = [0., 0.8, 0.8, 0.8, 0.9, −0.1, 0., 0., 0., 0.]
The cell with the highest activation level is the cell at index 4 in the array above. The calculation for the activation
level of this cell was calculated by: Ai = 1 − 0.1 · (1 + 0) = 0.9 here we see that the cell is less inhibited by the cell
Ii+1 and thereby giving a higher activation level. This is also what we know as lateral inhibition, we can think of this
as the cells having side connections which as we saw inhibit the activation of the cells, so that the the signal they
send to the brain is exaggerated in areas where there is a drop in input stimulation. As we see this exaggeration also
takes place in the cell at index 5, but opposite. This can be thought of as the eye making the intensity bigger and
lower on each side, and thereby increasing the contrast. All of this simulates the analysis the cells in the optic nerve
does before the information reaches the brain.

Equipping a threshold function?


Now the cells are equipped with a basic threshold function. As we have a binary input we can define the threshold
as being: t = 0.8, but do note that it is only in this particular case we can create a threshold function with a
constant value. So the function we create only has to compare each element in vector we do this in pseudo code as:
if (Ai > t) then Ai = T rue. Having implemented this we get the output below:
[F alse, F alse, F alse, F alse, T rue, F alse, F alse, F alse, F alse, F alse])
So for this threshold value it is only the cell at index 4 that activates. It should however also be kept in mind that
by edge detecting this way, we can’t determine if the edge takes place between the cells: Ii and Ii − 1, Ii and Ii + 1

Question 2 - Optical illusion


Now a new input vector is given:
I = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]
What is the activation of the cells?
We use the same formula and function to calculate the activation levels for the new input we are given. The output
then becomes:
A = [0., 0., −0.1, 0.9, 0.8, 0.7, 1.7, 1.6, 1.5, 2.5, 2.4, 2.3, 3.3, 3.2, 3.1, 4.1, 4., 0.]

1
Again it cam be observed that exaggeration close to the edges between different light intensities takes place. For this
input it is very clear that that the activation’s have ”peaks”and ”valleys”all depending on the neighbouring cells
input values.

How does the activation profile fit the input profile?


We see that the input profile has some very clear edges between the light intensities. As mentioned before this is the
lateral inhibition taking place, and creating a bigger contrast between light intensities. This does make it easier for
us to edge detect, as we can see were the edges are as stripe of higher or lower intensity. This is why there is a clear
practical use for lateral inhibition. It should also be noted that the threshold function from question one would not
work on this input, as the threshold would have to be a variable calculated by determining where the difference in
activity is biggest.

What optical illusion does this describe?


This is a 1 dimensional description of the “Mach Bands” which can be seen in figure 1 below. The Mach Bands
creates the illusion that light intensity is bigger or lower close to edges. As we can see this is an illusion, as the input
profile does not have higher or lower values when close to an edge.

Figur 1: The Mach Bands illusion over different light intensities.

Question 3 - Convolution
In this question we have to use convolutions to calculate the activation levels of the cells from question 1 and 2. We
use the kernel: [−w, 1, −w] and use the sci-py package to do the actual convolution, the function used is: conv2d,
which as input takes the image as matrix and then the kernel. If we look at the original way of calculating the
activation levels, it is clear that it is the sum of neighbouring cells multiplied by a weight.
After redoing Question 1 and 2 we get the following results: (Note that i removed first and last values in the arrays)

Question 1:
Input: [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]
Activation levels: [0.8, 0.8, 0.8, 0.9, −0.1, 0., 0., 0.]

Question 2:
Input: [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]
Activation levels: [0., 0., −0.1, 0.9, 0.8, 0.7, 1.7, 1.6, 1.5, 2.5, 2.4, 2.3, 3.33.2, 3.1, 4.1, 4.]

So it is clear that we get the same output, when solving the calculation problem as a convolution. This is very use
full when we have to calculate activation’s for inputs with 2 dimensions.

2
Question 4 - Mona Lisa
In this question we will make the kernel 2 dimensional which in terms makes it a matrix. When doing convolutions
in 2 dimensions, we use the formula:
XX
fout (x, y) = w ∗ fin (x, y) = w(u, v)fin (x + u, y + v)
v u

Where w is our weight, which we define as w = 0.1, u and v denote the indexes in our kernel, and x,y is the index
in our image. Note that in practice this is implemented in the scipy function: “conv2d”.

Activation levels calculated and displayed as image


In figure 2 below, we can see the different activation levels calculated and displayed as images in the grey scale color
map. From the plot it can be observed, that the kernel does enhance the edges. All though it blurs finer details in
the image, it does create a greater contrast between the different light intensity’s. This is especially visible around
the eyebrows for N = 20 and N = 25, where they stand out as a clear contrast to the light skin. The result of lateral
inhibition can especially be seen on the border between hair and background, on the plot for N = 25. We can see
that a halo of greater intensity is created. Although faint this can also somewhat be seen on the edge between the
clothes and the skin. So to sum up, in general we can see that light colors become lighter and dark colors become
darker. Translated to the human eye it means that the cells increase or decrease their firing rate when close to an
edge, which is part of the analysis that takes place in the optic nerve before the signal reaches the brain.

Figur 2: Image of Mona Lisa with different N- Values defining the kernel scales.

So we do get the best results for values of N > 15, as the edge enhancement is quite faint at lower values. Even
though the image does start to blur out, the actual edge enhancement becomes even more visible for larger kernel
scales as seen for N = 25. If we still want to keep a descent quality in the image, we should not go higher than
N = 15 because the image starts to blur out after these values. The reason the kernel of scale N = 1 does not work
very well, is most likely because the edges in a real image are not as sharp as we saw in question 1 or 2, but have a
“softer” transition between light intensities.

3
Equiping the cells with a threshold function
We equip the cells with a threshold function we define as: xi > µx +2·σx ,where xi is the individual cells activation,µx
denotes the mean of the activation levels and σx is the standard deviation. When defining the threshold this way,
we get a suitable value of which the edges are defined, and 95% of the activation levels will be lower than this value.
Also by doing it this way we make sure that the activation level is determined relative to the activation values in
the image. I did try using 1 · σ instead, but ended up with to many cells being deemed active, for any clear edge
detection to take place. I also tried with 3 · σ, which only gives us 0.27% of the activation values, and then we only
see the really sharp edges, because they are the ones with that high activation levels.
As we see in figure 3, the value of N needs to be from around 15-20, before the line detection become somewhat
consistent. We do also see in figure 3 that when N is 25 it does start to miss some precision and loose out on some
of the finer edges.That said, the threshold function does catch some prominent edges at values of N = 5 already.
The big edge it detects at N = 5 is the before mentioned contrast between the background and the hair. But as can
be seen it is only the cells right on the edge between the hair and background which trigger the threshold function.
In summary from my own qualitative assessment the kernel scales with the results in terms of edge detection is the
scale N = 15. The kernel of this scale manages to both detect both prominent and not so prominent edges., thous
displaying which of the cells have been inhibited less than their neighbouring cells.

Figur 3: Image of Mona Lisa with different N-Values and with the threshold function implemented.

4
Question 5 - Hermann Grid
The Herman Grid illusion, is the illusion of “dots” being present in the space between 4 of the cubes in the grid. This
illusion takes place because of lateral inhibition and and to be more precise because the cells have higher activation
levels in the space between two boxes than in the intersections between 4 white lines. The reason for this is, that
the cells in between 2 boxes, receive less inhibition from their neighbouring cells as some of them are of a lower light
intensity. The Herman grid does however only occur in our peripheral sight, as this is the “place” our sight detects
differences in light intensities. This is the exact reason we do not see the illusion if we focus our view on one exact
intersection between the white lines. When inspected up close, we can also see that for the kernel scale of N = 3
gray lines also form in the middle of the white stripes. This is the same concept, and proves why we need our kernel
to be big enough, to enable it to look at both the right and left edge simultaneously. As can be seen in figure 4, our
kernel experience the illusion the most for an N values of around 3-6, as the grey dots start blur out when using
higher dimensions for our kernel. So to sum up, we need a kernel big enough to “see” multiple edges but not so big
that it starts to blur the image.

Figur 4: Herman Grid after convolutions for different n values.

You might also like