# Image Interpolation Based on Spiking Neural Network Model
## 4 Proposed Method
### Proposed SNN Model for Edge Detection
It is known that HVS does not linearly calculate the difference between the gray-level values of pixels like the gradient, but it determines this difference according to the firing levels of neurons with inhibitory and excitatory synaptic connections [42]. Therefore, it is aimed at detecting the edge directions in a 3 \(\times\) 3 neighborhood by using two different synaptic matrices for each edge direction in this study. If the neurons M\({}_{\rm A1}\) or M\({}_{\rm N2}\) generate spikes at certain intervals, these generated spikes will be transmitted to neuron O\({}_{90}\) in the output layer. In the proposed model, the pairs of neurons in the intermediate layer have only excitatory synaptic connections with the corresponding neuron in the output layer. Depending on the intensity of the synaptic signals from M\({}_{\rm A1}\) and M\({}_{\rm A2}\), the output neuron O\({}_{90}\) will also generate spikes at certain intervals. A similar situation is realized in other output neurons (O\({}_{0}\), O\({}_{45}\), and O\({}_{135}\)), and edge images are obtained at four different angles. The CIF neuron model used for visual attention [29] is applied to the proposed SNN in this study. (\(x,y\)) in the SNN represents the coordinates of the pixels corresponding to the receivers. The peak conductivity values \(q_{\rm cr}\) and \(q_{ih}\) of excitatory and inhibitory receptors are calculated by Equation (3). \(G_{\rm x,y}\) is the gray-level value of the pixel at the (\(x,y\)) coordinate. \[q_{\rm cr}(x,y)=\alpha G_{\rm x,y};\ q_{ih}(x,y)=\beta G_{x,y} \tag{3}\]  
where \(\alpha\) and \(\beta\) are the coefficients used to normalize the gray-level values between 0 and 1 and are accepted as 1/255. For clarity, only the equations for the M\({}_{\rm A1}\) neuron are given below. Calculations for each neuron in the intermediate layer are performed with the same equations. \[\frac{dg_{ex}(t)}{dt}=-\frac{1}{\tau_{ex}}g_{ex}(t)+\sum_{(x,y)\in RF}\frac{w_{ex}( x,y)q_{ex}(x,y)}{A_{ex}} \tag{4}\]  
\[\frac{dg_{ih}(t)}{dt}=-\frac{1}{\tau_{ih}}g_{ih}(t)+\sum_{(x,y)\in RF}\frac{w_{ ih}(x,y)q_{ih}(x,y)}{A_{ih}} \tag{5}\]  
where \(\tau_{ex}\) and \(\tau_{ih}\) are the time constants for excitatory and inhibitory synapses, respectively. \[I_{syn}=-g_{ex}E_{ex}-g_{ih}E_{ih} \tag{6}\]  
where \(I_{syn}\) is the total synaptic current from the synaptic connections. Equation (7) which is the analytical solution to Equation (2), is used to calculate the membrane potential \(v(t)\) of the M\({}_{\text{A1}}\) neuron [35]. \[v_{M_{A1}}=\bigg{(}\frac{1}{g_{I}}\bigg{)}\bigg{\{}\bigg{(}-\exp\bigg{(}\frac{ g_{I}t}{c_{m}}\bigg{)}\bigg{)}\big{(}I_{syn}+70g_{I}+g_{I}E_{I}\big{)}+I_{syn}+g_{I}E_{I} \bigg{\}} \tag{7}\]  
In the matrix m\({}_{\text{A1}}\), which determines the synaptic connections of the neuron M\({}_{\text{N1}}\), \(g_{ex}\) is the total conductivity of the receptor of the central pixel and receptors of its left and right neighbors. \(g_{ih}\), on the other hand, refers to the conductivity of the receptors of the six pixels located on the top and bottom rows of the central pixel. For the neuron M\({}_{\text{A2}}\), the connections to the receptors of the same pixels are expressed as in the matrix m\({}_{\text{N2}}\). In m\({}_{\text{N2}}\), the center pixel and its left and right neighbors have inhibitory connections and the other neighbors have excitatory connections. Calculations for M\({}_{\text{A2}}\), M\({}_{\text{B1}}\), M\({}_{\text{B2}}\), M\({}_{\text{C1}}\), M\({}_{\text{C2}}\), M\({}_{\text{D1}}\), and M\({}_{\text{D2}}\). If the membrane potential of a neuron in the network achieves its threshold value, the neuron generates spike(s). The generated spikes are stored in a separate spike train for each neuron. S\({}_{\text{A1}}\), the spike sequence of the M\({}_{\text{A1}}\) neuron, is determined by Equation (8). \[S_{A1}(t)= \begin{cases}1&\text{if neuron $i$ fires a spike at time $t$}\\ 0&\text{if there is no spike at time $t$}\end{cases}