<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>High Performance Median Filtering Algorithm Based on NVIDIA GPU Computing</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>Placido Salvatore Battiato University of Catania</institution>
          ,
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>-Median filtering technique is often used to remove additive white, salt and pepper noise from a signal or a source image. This filtering method is essential for the processing of digital data representing analog signals in real time. The median filter considers each pixel in the image in turn and looks at its nearby neighbors to determine whether or not it is representative of its surroundings. It replaces the pixel value with the median of neighboring pixel values. The median is calculated by first sorting all the pixel values from the surrounding neighborhood into numerical order and then replacing the pixel being considered with the middle pixel value. We have used graphics processing units (GPUs) to implement the post-processing, performed by NVIDIA Compute Unified Device Architecture (CUDA). Such a system is faster than the CPU version, or other traditional computing, for processing medical applications such as echography or Doppler. This paper shows the effect of the Median Filtering and a comparison of the performance of the CPU and GPU in terms of response time. Index Terms-GPU programming, performances, filters, images</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>I. INTRODUCTION</title>
      <p>
        The noise and distortion are the main factors that limit the
capacity of data transmission in telecommunications affecting
the accuracy of the results in the signal measurement systems,
in communications and signal processing [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. The
noise reduction and distortion removal are major problems in
applications such as: cellular mobile communication, speech
recognition, image processing, medical signal processing,
radar, sonar, and any other application where the desired
signals cannot be isolated from noise and distortion. Noise is
defined as an unwanted signal that interferes with the
communication or measurement of another signal. Noise itself is an
information-bearing signal that conveys information regarding
the sources of the noise and the environment in which it
propagates. Impulse noise is caused by malfunctioning pixels
in camera sensors, faulty memory locations in hardware, or
transmission in a noisy channel. The noise can be classified
by its spectral characteristics, in discrete sense, the white noise
signal constitutes a series of samples that are independent
and generated from the same probability distribution Gaussian
Noise, given a Gaussian distribution, it is concentrated around
a mean frequency and about 70% of noise is in the interval
[ ; + ] and about 95% in the interval [ 2 ; +2 ]
where is the standard deviation. The white noise is defined
as an uncorrelated random noise process. Random noise has
Copyright c 2016 held by the authors.
the same power at all frequencies and it would necessarily
need to have infinite power, and it is therefore a theoretical
concept only. It cannot be removed by a traditional low-pass
filter or band-pass filter.
      </p>
      <p>The salt and pepper noise or impulsive noise is visible
in images and is similar to many black and white spots and
is generated during image acquisition. It is characterized by
positive or negative peaks that saturate the pixels of the image.
An example of salt and pepper noise in images is shown in
figure 6b. An example of white noise audio signal is shown
in figure 7a. A white noise is also a sound that contains every
frequency within the range of human hearing and it can be
generated on a sound synthesizer. Sound designers can use
this sound, with some processing and filtering, to create a
multitude of effects such as wind, surf, space whooshes, and
rumbles. The analog voltage signal produced by the
phototransistors is converted into a digital or numeric value, the
ADC adds broad spectrum noise or white noise. The Median
filter is a nonlinear digital filtering technique often used to
remove salt and pepper noise.</p>
      <p>Computing the neighborhood requires more computation
time in a post processing step. More recently, the opened
perspectives have been offered by modern GPUs that allow
us to develop CUDA-based filters, which will be shown as
the fastest median filter implementation known. The surgical
applications such as echography or Doppler to biomedical
research and clinical medicine for real-time image request image
brightness and exceptional image quality. In this paper, the
first section explains the filtering problem and mathematical
model. In CUDA section, we have presented the algorithm
implemented using CUDA of median filter comparing the
performance of CPU implementations of filtering effects,
analysing one dimensional (1D) audio signal.</p>
      <p>II. ANALOG TO DIGITAL CONVERSION</p>
      <p>
        In Signal Theory, Sampling is a technique that allows the
conversion of a continuous signal (for example audio) to a
discrete-time signal evaluating the amplitude of that signal at
regular time interval (sample time, ts) [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] and translate
it to a binary word. Each of these amplitude is converted to
the respective binary code through an ADC (Analog to digital
converter). The ADC has a voltage reference that is used to
understand the right binary value of each sample. An example
is shown in figure 1 where a continuous signal is sampled
and then converted. The output string of figure 1 is f000
100 101 001 010 101 111 111 001 000 001 011 101 110
101g, that is a bipolar 3 bits codification of 16 samples. If
the codifications uses 8 bits, the digitalized output signal is
more accurate and closer to the original. Another important
parameter is the sampling frequency fs = 1=ts.
      </p>
      <p>
        Shannon Theorem establishes the minimum sampling
frequency fs so that the continuous time signal can be
reconstructed from the discrete time samples without distortion and
error [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]:
fs &gt; 2 fm
(1)
where fm is the maximum frequency in the spectrum of the
analog signal to sampling. Generally for a good result it is
imposed fs = 5 fm or fs = 10 fm. For example, the standard
audio coding format (.wav) is sampled at fs = 44:1khz and
16/24/32 bits per sample.
      </p>
      <p>
        Digital filters [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] are specific causal discrete-time LTI
systems. They can be implemented and simulated on digital
microprocessors or specialized processors such as DSPs—
Digital Signal Processors. The advantage over analog filters
is twofold:
they can be reprogrammed by software on the same
hardware;
the filter coefficients can be changed in real time, thereby
obtaining “adaptive” filters.
      </p>
      <p>The main types of digital filters are: Infinite Impulse
Response (IIR) filters, and Finite Impulse Response (FIR) filters.
The first class of digital filters is distinguished by having an
impulse response which continues indefinitely. A FIR filter is a
causal LTI system whose impulse response is of finite duration;
the transfer function of a FIR filter turns out to be a polynomial
in z 1. Essentially, the filtering process is a function in which
the value that assumes the output sample is determined by
h(n) that operates on neighbors too. The filter operates on a
window w of N elements with a width smaller than the signal
duration. For this reason it is called local operator. Two classes
of filter are distinguished: Linear and Non Linear. The linear
filtering operation returns an output that is a linear combination
of the input. A non linear filter is a filter whose output is not
a linear function of its input and it is based on rank function
for operation of erosion and dilation. The Fourier transform is
a reversible, linear transform used only for linear filters.</p>
      <p>In an invariant-time system, in order to filter a signal we
need to implement the convolution of the input signal x(t)
with the filter transfer function h[t]
y(t) = x(t) h(t)
(2)</p>
      <p>A discrete-time linear system transforms the input
succession x[n] 2 Z to the output succession y[n] 2 Z across the
discrete convolution with the discrete transfer function h[n]
y[n] =
1
X x[k] h[n</p>
      <p>k] =
so that for a discrete-time filter the output is a weighted sum
of the values taken from the input at the current time and at
earlier times. This is described by the following operation:
y[n] = h0x[n]+h1x[n 1]+
+hN x[n</p>
      <p>N ] =
(4)
where hi are the filter coefficients that determine the impulsive
response and N is the filter order.</p>
      <p>N
X hix[n i]
i=0</p>
      <sec id="sec-1-1">
        <title>A. Example: mobile mean filter</title>
        <p>A simple example of FIR filter is the mobile mean filter, the
coefficients b0; ; bN with N=2 , are determined by equation
(5)
bi =</p>
        <p>1
(N + 1)
(5)</p>
        <p>
          Median filtering [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ] is a non-linear, low-pass filtering
method that can remove white or salt and pepper noise from
an image or an audio signal. It operates directly on samples
of acquired signals or images and it has the tendency of
edgepreserving smoothing. Median filtering means that for each
input sample it is considered a window of N samples about the
pivot sample, with N an odd number 2 N, where the current
pivot sample is in the middle. The window of samples are
sorted in ascending or descending order and then the median
sample is taken. The median is always positioned in the middle
of the window. Figure 4 shows an example of median operation
and figure 5 shows 6 possible masks for the 1D and 2D
domain. In our case, a ROW mask has been chosen for the
window.
        </p>
        <p>Fig. 4: Example of Median filtering operation on a window
of 5 samples. After sorted, the central element is the Median,
for this reason the window elements must be odd.</p>
        <p>Two examples of median filtering are shown in figure 6 for
an image (2D domain) and in figure 7 for an audio signal (1D
domain). It should be recalled that if m is the median among
an ordered set of numbers, the same amount C of numbers
will precede and follow that median. If the cardinality of that
set is N then it follows that</p>
        <p>C = (N
1)=2
(6)
then C represent the width of the domain boundary. The
condition for the 1D signal is that the first term of the samples
C and the last term C can not be filtered because they have
no neighbours. These samples will be copied without any
processing. The novelty consists in determining the median
element without ordering the window. For each mi 2 w it is
useful to count the number of elements equal to, greater and
lower than each current element in the window, mi 2 w is the
median if
9 exactly C elements &gt; mi
9 at least C + 1 elements = mi
9 exactly C elements &lt; mi
(7a)
(7b)
(7c)
where w denotes the window and mi represents the i-th
element of w, i = f1 : : : N g. Of course, all the said conditions
must be satisfied.</p>
      </sec>
      <sec id="sec-1-2">
        <title>C. Computational complexity</title>
        <p>
          The computational complexity (CC) defines the number of
operations required for the extraction of the median from
the window of N elements. The CC in an efficient sorting
algorithm is estimated as N ln(N ) [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ]. Instead in the counting
algorithm CC is estimated as N N because each element mi
of the window w is compared to all others and itself. Since
N operations are executed in parallel in a GPU we could say
that the computational complexity is reduced to N . Figure 8
shows the comparison between sorting algorithm and counting
algorithm in terms of computational complexity.
        </p>
        <p>Counting algorithm equals sorting algorithm in terms of
computational complexity when N=10.</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>IV. CUDA CUDA—Compute Unified Device Architecture—is a parallel computing platform and programming model used with a GPU for general purpose computing simple and elegant.</title>
      <p>
        The developer still programs in the familiar C, C++ and
incorporates extensions of these languages in the form of
a few basic keywords [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. Programs written in
CUDA are compiled by NVIDIA’s nvcc compiler and can
be run only on NVIDIA’s GPU’s. The task of modifying the
solution to run parallel operations, however, is given to the
programmer. CUDA ensures only that after this modification
parallel operations can be run on simultaneous GPU threads.
A CUDA program may be run on any number of processor
cores, and only the number of processors needs to be known
at runtime system. A typical CUDA program consists of two
parts: the main executing serially on the CPU (the host), and
the kernel, called by the main, which is executed in parallel
on the GPU (the device). Several smart solutions have been
developed to take advantage of such a parallel paradigm [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ],
[
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] and modularisation [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ], [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ], [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ]. In this work, the
median filter has been implemented in CUDA as an extension
to the C programming language.
      </p>
      <sec id="sec-2-1">
        <title>A. CPU versus GPU Architecture</title>
        <p>In this section the main differences between the CPU and
the GPU are analysed. Originally GPUs—Graphic Processing
Units—were used to accelerate the drawing of lines, circles
and arcs, rectangles, and character bitmaps, then were also
used to perform computations. Instead the CPU architecture
allows performing computations directly and it is more evolved
and complex with respect to the GPU. GPUs have far more
processor cores than CPUs, but because each GPU core runs
significantly slower than a CPU core and does not have
the features needed for modern operating systems, it is not
appropriate for performing most of the processing in
everyday computing. GPUs are more suited to compute-intensive
operations such as video processing and physics simulations.
A GPU is simpler than a CPU constituted by full adders,
multipliers and comparators. A program is executed in an
element called thread. The GPU has multiple hardware threads
per core comparing to CPU that it is constituted by
multicore (2,4,8 or 16 ) and single thread architecture. The CPU
architecture has multi-core and multi-thread at the same time.</p>
        <p>Computing threads on a GPU are organized into thread
blocks and grid. Each thread belonging to the same block
communicates with others via a shared memory and can be
synchronized manually by the user. CUDA contains special
C function called kernels, which are simply C code that is
executed on the GPU on fixed number of threads. Prior to
launching a kernel, all the data required for the computation,
must be transferred from the host (CPU) memory to the device
(GPU) memory across the PCI Express bus. This operation
takes a considerable time, because the PCI Express bus is
managed by the operation system according to the system
requirements and not the single job. If the amount of data
is not great, the total time (the computation time plus the data
transfer time) may be larger than the execution time of the
serial program which does not require data transfer because it
operate on the RAM locations directly.</p>
        <p>Threads organization in grids and blocks is a logical
structure that the user defines at the time of the call to the global
function. In the next subsection IV-C we will see how to call
a global function and how define the logical structure during
call.</p>
      </sec>
      <sec id="sec-2-2">
        <title>B. CUDA paradigm</title>
        <p>
          To write a program in a parallel paradigm we need to follow
some rules reported in listing 1 [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ], [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ]. This procedure is
necessary to ensure the proper functioning and data transfers.
__global__ void MyKernel(...){...};
//allocates variables in DEVICE
cudaMalloc(void** devPtr, size);
//Copy variables from HOST to DEVICE
cudaMemcpy(dst, src, size, kind);
//call cuda MyKernel
MyKernel&lt;&lt;&lt;bkdims,thdims&gt;&gt;&gt;(...);
//Copy variables from DEVICE to HOST
cudaMemcpy(dst, src, size, kind);
Listing 1: CUDA paradigm: sequence of steps for executing a
function on a GPU
        </p>
        <p>The keyword global indicates a function that runs on
the device and is called from host code. Such a function is
called kernel and runs in multiple instances on several blocks
and threads. The number of blocks and threads is determined
by using the &lt;&lt;&lt;; &gt;&gt;&gt; symbols, with bkdims and thdims
indicate the number of blocks and threads to execute.</p>
        <p>cudaMalloc(. . . ) is used to allocate variables in the device
memory, it takes the parameter (void**) devPtr, a variable
address to allocate; size is an integer requested to allocate
size in bytes, generally it is used N*sizeof(. . . ) to calculate it.</p>
        <p>cudaMemcp(. . . ) is used to copy data from host to device
end vice versa; the needed parameters are: dst destination
memory address; src source memory address; size the
requested allocation size in byte and kind the type of transfer
and is a specific token
cudaMemcpyHostToDevice
cudaMemcpyDeviceToHost
the first copies the data through the PCI Express bus from
HOST to DEVICE, instead the second from DEVICE to
HOST.</p>
        <p>cudaFree(. . . ) is used to free device memory, being limited,
when the computation is ended. In this manner, we indicate
the device which are the useful variables to keep in memory
for other calculation and which are not.</p>
        <p>
          cudaError: each cuda function returns an enumerator type,
named cudaError or simply “cuda status”. It indicates if the
operation in the GPU was successful or not. If all is well,
it returns the cuda status: cudaSuccess, in case of error the
cuda status will be a keyword describing the type of error. A
complete list of cuda errors can be found on NVIDIA site in
“related page/cudaError” [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ].
        </p>
      </sec>
      <sec id="sec-2-3">
        <title>C. Indexes linearization</title>
        <p>Indexes linearization is an important issue in cuda
programming, so great attention is required. Indexes linearization
technique allows us to express a multidimensional index as one
dimensional. Let us express the concept with some example.</p>
        <p>1) Example of indexes linearization, from 2 indexes to 1:
Assume that we have a squared sheet and y is the row index,
row is the row size, x is the column index and col is the
column size; the element (y; x) = (2; 5) in a linear index is
determined by equation (8)</p>
        <p>Id = y row + x
(8)
as shown in figure 9; note that the index starts from 0.</p>
        <p>2) Example of indexes linearization, from n indexes to 1:
This example extends the previous, i.e. assume to have a new
dimension where k is the sheet index and sheet is the block
size; now an element in the position (k; y; x) = (2; 2; 5) has
the linear index determined by equation (9)</p>
        <p>Id = k row
col + y row + x
(9)</p>
        <p>If we have one more dimension, for example the ream index
r, the linear index Id is determined by equation (10)
Id = r sheet row col + k row col + y row + x (10)
Fig. 9: example of indexes linearization from two to one index.
Fig. 10: Example of indexes linearization from n to one index</p>
        <p>In general, assume that I Zn with n 2 N is a discrete and
limited set, so that for each dimension it exists a maximum
Mi and a minimum mi:</p>
        <p>I =&lt; m1; M1 &gt;&lt; m2; M2 &gt;</p>
        <p>n
= Y &lt; mi; Mi &gt;</p>
        <p>i=1
the i-th volume is defined by
&lt; mn; Mn &gt;
so index Id is determined by equation (13)</p>
        <p>Vi = (Mi</p>
        <p>mi)
n
Id = x1 + X xj
j=2
j 1
Y Vi
i=1</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>V. ALGORITHM IMPLEMENTATION</title>
      <p>This section explains the implementation of an efficient
sequential and parallel algorithm for a median filtering. The
1D audio signal is called track in. In a sequential approach,
to determinate the median from a window of N elements, first
of all, the window must be sorted in ascendant or descendant
order, then the median element can be taken. This element is
situated in the middle of the sorted window, for this reason N
must be an odd number, as shown in figure 4 with N = 5. The
Serial Median Filter (SMF) is shown in Listing 2, relating to
input audio track in. Then, C is calculated using equation (6)
and the window of N elements is created. Moreover, the first C
samples of the input track (track in) are copied from it to the
output track (track out) because they are in the boundary of
(11)
(12)
(13)
the track and also the last C samples. Finally, the real Median
filter is applied, and in order to filter all samples of track in
the window must select from the beginning to the end of it,
so that a scrollable index k is implemented for the loop (k
starts from C because the first track in element starts from
0 and it ends with the samples C that represent the total
number of samples in filter); therefore the window is filled
with the samples as shown on the top of figure 4 and the
median function is on the window. Median function sorts the
window and returns the C-th element that is the median in
the window. These procedures are repeated for each sample
of interval [C; sample C]
// serial median filter SMF
void SMF(int* track_in, int* track_out) {
int c = (N-1)/2;
int window[N] = {0};
//copy the first c boundary elements from TRACK_IN to</p>
      <p>TRACK_OUT
for (int i = 0; i &lt; c; i++)
track_out[i] = track_in[i];
//copy the last c elements from TRACK_IN to TRACK_OUT
for (int i=samples-c; i&lt;samples; i++)
track_out[i] = track_in[i];
//scroll the input track
for (int k=c; k&lt;samples-c; k++) {
//fill the window
for (int i=0; i&lt;N; i++)
window[i] = track_in[k-c+i];
track_out[k] = Median(window, N, c);
}
}
// extract the median element from input array w
int Median(int *w, int N, int c) {
bool exchange = true;
int last = N-1, i=0;
while (exchange) {
exchange = false;
for (i = 0; i&lt;last; i++) {
if (w[i]&gt;w[i+1]) {
int tmp = w[i];
w[i] = w[i+1];
w[i+1] = tmp;
exchange = true;
}
}
}
last--;
}
return w[c];
Listing 2: Serial algorithm used to implement the Median filter.</p>
      <p>We have used the property described in equation (7) to
determine the median. An example of application is shown
in figure 11 and we can find on the top an input array, on
the bottom the output array, instead, in the center three array:
major (M), equal (e) and minor (m). These arrays have the
same dimensions of the window and take into account the
number of elements greater, equals or minor than the current
element. In the example of figure 11, the number 6 has two
elements much greater in the window, one element equals to
it and two minor elements. In this case the number 6 has
all requirements to be the median element as specified in
equation (7).</p>
      <p>The parallel algorithm (CMF—Median Filter with CUDA
extensions) is shown in listing 4, that is the global
function, furthermore the cuda model is shown in the listing 1
Fig. 11: Example of median filtering operation with a window
of 5 elements executed in the GPU with the CMF method
with memory allocations and data transfer. It is important to
determine the number of threads for the simulation of the
filter. Each sample must be compared to all samples of the N
elements of the window to obtain the total number of threads:
Ttot = samples</p>
      <p>N
(14)
the maximum number of threads per core in the GPU (1024)
will be indicated as nthread. So, as shown in figure 12, each
block will represent the dimension bkarea = bkd N where
bkd is gived by</p>
      <p>nthread
bkd = (15)</p>
      <p>N
finally,we have assumed a mono grid of dimension grd 1 1,
the total block with dimension bkd N will be:
gnd = Ttot + 1 = samples + 1 (16)</p>
      <p>bkarea bkd</p>
      <p>The global CMF function is in listing 4. While in the
sequential algorithm k was a scrollable index, now in the parallel
version it is a global index as in the indexes linearization,
example IV-C1, therefore the k-th sample will be assigned
to the k-th thread with a correspondence 1 : 1. The term C
is calculated using equation (6) and takes into account the
boundary condition, defining another index i. The column
index is used to create the window. For each sample, arrays
with major, equal and minor elements are created in order to
determine the median mi in the window as shown in figure 11.
Each thread executes two comparison to determine the major,
minor or equal sample. The median can be found by observing
the three arrays vertically. The median is present if a column
complies with the specifications (7). Note that the sum of
number in this column is always the window width of N.
//CMF = Median Filter with CUDA extension
__global__ void CMF(int* in, int* out, int c) {
// k = input array index
int k = c+blockDim.x*blockIdx.x+threadIdx.x;
int M[N] = {0}; //major array
int e[N] = {0}; //equal array
int m[N] = {0}; //minor array
//window index
int i = k-c+threadIdx.y;
for (int j=k-c; j&lt;k-c+N; j++) {
if (in[j]&gt;in[i]) M[threadIdx.y]+=1;
else if (in[j]&lt;in[i]) m[threadIdx.y]+=1;
else e[threadIdx.y]+=1;
}
for (int j = 0; j&lt;N; j++) {
if (M[j]==c || m[j]==c || e[j]&gt;=c) {
out[k] = in[k-c+j];
return;
}
}
}
Listing 4: Parallel algorithm used to implement the Median
filter in CUDA.</p>
    </sec>
    <sec id="sec-4">
      <title>VI. EXPERIMENT</title>
      <p>For computing results, two different GPUs and an Intel
CPU, in two different OSs, have been used: the NVIDIA’s
GeForce 820M in a node with Windows 10, the NVIDIA’s
GeForce GTX 480 in a node with Linux MIND 14.4 and the
Intel Core i7-4510U in a node with Windows 10. The 820M
is considered an entry level GPU, instead the GTX 480 is a
midrange GPU. The main features of the three devices are
given in Table I.
the realization of real-time systems in image processing. These
results have been obtained by filtering the audio signals as
shown in figure 7 with different duration and several sample
numbers. During the experiments different window sizes have
been used. The work on 1D data can be easily extended to 2D
data.</p>
      <p>The characteristic of the different audio tracks are reported
in Table II and Table III</p>
      <p>Figure 13 shows the simulation results: the numbers of
samples to process are represented in the x axis; the y axis
represents the response time of the SMF and CMF expressed
in milliseconds. Figure 13a, 13b and 13c show the obtained
results varying the window width from 5 to 9 and then to 15,
respectively. Data have been expressed in logarithmic scales
and the results highlight the behavior of few samples during
filtering. The CPU graphic has a computational complexity,
when the filtering of the samples increases, the time increase
exponentially. For a few samples the GPU uses more time
than the CPU. The reason is the data transfer from the host to
device and vice versa through the PCI Express bus, this time
isn’t negligible. The PCI Express bus is managed by the OS,
the data flow through the bus when it isn’t busy. A dedicated
bus will make the computation more easy. In figure 7 we can
see the median effect of the filter in noise reduction. The noise,
clearly, can’t be totally removed but is reduced. In fact, the
spectral analysis still reveals the presence of noise. The same
data of figure 13 are reported in the table IV with a more clear
result.</p>
      <p>To highlight the behavior of a lot of samples during filtering,
figure 13c reports a linear scale in figure 13d. The speed gain
is about 2 for the 820M and 4 for the GTX 480. In figure 13e
and 13f are reported the ratio between the CPU performance
and GPU. The trend of the three graphs is ascendant, this
demonstrates that GPU computing is more powerful than CPU
computing.</p>
      <p>To measure the execution time was used the following code.
#include &lt;time.h&gt;
float duration = 0;
start = clock();
/*your codes here*/
end = clock();
//time in milliseconds
duration = (float)(end-start)*1000...
.../CLOCKS_PER_SEC;</p>
      <p>Listing 5: Execution time measure method</p>
    </sec>
    <sec id="sec-5">
      <title>VII. CONSIDERATIONS</title>
      <p>In this section we evaluate the extension of this work to
a 2D domain in the real-time scenario. The total number of
samples is 100 106
s = d fs =
d</p>
      <p>Ts
where s represents samples and d represents the duration. So
that the samples per sec (sample rate = sr) are given by</p>
      <p>s
sr = = fs (18)</p>
      <p>d
Supposing negligible the data transfer time for many samples,
the elaboration capability of the GeForce GTX 480 is
evaluated by:
srGT X480 =
s
tr
=
n
i
a
G
1:5
0:5
2
1
0
4
3
2
1
0
103
104</p>
      <p>105 106
Number of samples
107</p>
      <p>108
(c) Case N=15 in logarithmic scale
103
104</p>
      <p>105 106
Number of samples
107</p>
      <p>108
(d) Case N=15 in linear scale
N=5
N=9
N=15</p>
      <p>N=5
N=9</p>
      <p>N=15
i7-4510U</p>
      <p>GeForce 820M
GeForce GTX 480
103
104</p>
      <p>105 106
Number of samples
107</p>
      <p>108
(a) Case N=5 in logarithmic scale</p>
      <p>i7-4510U</p>
      <p>GeForce 820M
GeForce GTX 480
103
104</p>
      <p>105 106
Number of samples
107</p>
      <p>108
(b) Case N=9 in logarithmic scale
105</p>
      <p>i7-4510U</p>
      <p>GeForce 820M
GeForce GTX 480
s 105
d
n
o
se 104
c
i
l
l
i
m
in 103
e
m
iT 102
e
s
n
sp 101
o
e
R</p>
      <p>100
sd 105
n
o
c
is 104
e
l
l
i
m
in 103
e
m
i
T 102
e
s
n
sp 101
o
e
R</p>
      <p>100
n
i
a
G
1:5
0:5
1
0
103
104</p>
      <p>105 106
Number of samples
107
108
103
104</p>
      <p>105 106
Number of samples
107
108
(e) Speed Gain of GeForce 820M
(f) Speed Gain of GeForce GTX 480.</p>
      <p>Fig. 13: Simulation results: Comparison between sequential algorithm and parallel algorithm in terms of response time. a) case
N=5; b) case N=9; c) case N=15; e and f) Representation of Speed Gain: CP UResponseT ime=GP UResponseT ime.</p>
      <p>1 106[samples] (20)</p>
      <p>Applying the CMF takes about 766 milliseconds. If we have
a video at 480p@24fps, it means we have the following sample
rate
22:1 106h samples i
sec</p>
      <p>(21)
In this case the GeForce GTX 480 can not be used for a
realtime filtering process on a video at 480p@24fps so that a more
powerful GPU is required.</p>
    </sec>
    <sec id="sec-6">
      <title>VIII. CONCLUSIONS</title>
      <p>
        Other similar works are “High Performance Median Filter”
[
        <xref ref-type="bibr" rid="ref17">17</xref>
        ] and “Parallel biomedical image processing with GPUs
in cancer research” [
        <xref ref-type="bibr" rid="ref18">18</xref>
        ] that concern the image processing in
medical application with median filtering technique using the
branchless vectorized median (BVM) filter [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ].
      </p>
      <p>In conclusion, the method reported by equation (7) is
effective for the CUDA implementation. The simulation results
demonstrate that is possible to obtain gain in response time
with an entry level GPU, allowing real-time image and audio
filtering. However, the bottleneck of these systems is the PCI
Express bus, for dedicated and direct bus through GPU/RAM
and CPU/ GPU the response time is reduced.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>M.</given-names>
            <surname>Woz</surname>
          </string-name>
          ´niak,
          <string-name>
            <given-names>D.</given-names>
            <surname>Połap</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Gabryel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R. K.</given-names>
            <surname>Nowicki</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          , and E. Tramontana, “
          <article-title>Can we preprocess 2d images using artificial bee colony?</article-title>
          ”
          <source>in Proceedings of International Conference on Artificial Intelligence and Soft Computing (ICAISC)</source>
          ,
          <source>ser. Lecture Notes in Artificial Intelligence</source>
          , vol.
          <volume>9119</volume>
          . Springer,
          <year>2015</year>
          , pp.
          <fpage>660</fpage>
          -
          <lpage>671</lpage>
          , DOI: 10.1007/978- 3-
          <fpage>319</fpage>
          -19324-3
          <fpage>59</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>D.</given-names>
            <surname>Polap</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wozniak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          , E. Tramontana, and
          <string-name>
            <given-names>R.</given-names>
            <surname>Damasevicius</surname>
          </string-name>
          , “
          <article-title>Is the colony of ants able to recognize graphic objects?” in Information and Software Technologies, ser</article-title>
          . Communications in Computer and Information Science, G. Dregvaite and
          <string-name>
            <given-names>R.</given-names>
            <surname>Damasevicius</surname>
          </string-name>
          , Eds. Springer International Publishing,
          <year>2015</year>
          , vol.
          <volume>538</volume>
          , pp.
          <fpage>376</fpage>
          -
          <lpage>387</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>M.</given-names>
            <surname>Wozniak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          , E. Tramontana, and G. Capizzi, “
          <article-title>A multiscale image compressor with rbfnn and discrete wavelet decomposition</article-title>
          ,”
          <source>in Proceedings of International Joint Conference on Neural Networks (IJCNN)</source>
          . IEEE,
          <year>2015</year>
          , pp.
          <fpage>1219</fpage>
          -
          <lpage>1225</lpage>
          , doi: 10.1109/IJCNN.
          <year>2015</year>
          .
          <volume>7280461</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>P.</given-names>
            <surname>Diniz</surname>
          </string-name>
          , E. da
          <string-name>
            <surname>Silva</surname>
            , and
            <given-names>S.</given-names>
          </string-name>
          <string-name>
            <surname>Netto</surname>
          </string-name>
          ,
          <source>Digital Signal Processing: System Analysis and Design</source>
          . Cambridge University Press,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>S.</given-names>
            <surname>Salivahanan</surname>
          </string-name>
          and
          <string-name>
            <given-names>A.</given-names>
            <surname>Vallavaraj</surname>
          </string-name>
          , Digital Signal Processing. McGrawHill
          <string-name>
            <surname>Education (India) Pvt Limited</surname>
          </string-name>
          ,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>M.</given-names>
            <surname>Juhola</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Katajainen</surname>
          </string-name>
          , and T. Raita, “
          <article-title>Comparison of algorithms for standard median filtering</article-title>
          ,
          <source>” IEEE Transactions on Signal Processing</source>
          , vol.
          <volume>39</volume>
          , no.
          <issue>1</issue>
          , pp.
          <fpage>204</fpage>
          -
          <lpage>208</lpage>
          ,
          <year>Jan 1991</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>C.</given-names>
            <surname>Nvidia</surname>
          </string-name>
          , “
          <article-title>Nvidia cuda compute unified device architecture programming guide</article-title>
          ,
          <source>” NVIDIA Corporation</source>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>J.</given-names>
            <surname>Sanders</surname>
          </string-name>
          and
          <string-name>
            <surname>E. Kandrot,</surname>
          </string-name>
          <article-title>CUDA by Example: An Introduction to General-Purpose GPU Programming</article-title>
          .
          <source>Pearson Education</source>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>[9] “https://developer.nvidia.com/cuda-zone.”</mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>F.</given-names>
            <surname>Bonanno</surname>
          </string-name>
          , G. Capizzi,
          <string-name>
            <given-names>G. Lo</given-names>
            <surname>Sciuto</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          , G. Pappalardo, and E. Tramontana, “
          <article-title>A novel cloud-distributed toolbox for optimal energy dispatch management from renewables in igss by using wrnn predictors and gpu parallel solutions</article-title>
          ,”
          <source>in Proceedings of IEEE International Symposium on Power Electronics</source>
          , Electrical Drives,
          <article-title>Automation and Motion (SPEEDAM), Ischia</article-title>
          , Italy,
          <year>June 2014</year>
          , pp.
          <fpage>1077</fpage>
          -
          <lpage>1084</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Pappalardo</surname>
          </string-name>
          , E. Tramontana, and
          <string-name>
            <surname>G.</surname>
          </string-name>
          <article-title>Zappala', “A CloudDistributed GPU Architecture for Pattern Identification in Segmented Detectors Big-Data Surveys</article-title>
          ,”
          <source>Computer Journal</source>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          , G. Pappalardo, and E. Tramontana, “
          <article-title>A mathematical model for file fragment diffusion and a neural predictor to manage priority queues over bittorrent</article-title>
          ,”
          <source>International Journal of Applied Mathematics and Computer Science</source>
          , vol.
          <volume>26</volume>
          , no.
          <issue>1</issue>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>F.</given-names>
            <surname>Bonanno</surname>
          </string-name>
          , G. Capizzi,
          <string-name>
            <given-names>G. Lo</given-names>
            <surname>Sciuto</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          , G. Pappalardo, and E. Tramontana,
          <article-title>“A cascade neural network architecture investigating surface plasmon polaritons propagation for thin metals in openmp</article-title>
          ,
          <source>” in Artificial Intelligence and Soft Computing</source>
          . Springer International Publishing,
          <year>2014</year>
          , pp.
          <fpage>22</fpage>
          -
          <lpage>33</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          , G. Pappalardo, and E. Tramontana, “
          <article-title>An agent-driven semantical identifier using radial basis neural networks and reinforcement learning</article-title>
          ,” in XV Workshop ”From Objects to Agents
          <source>” (WOA)</source>
          , vol.
          <volume>1260</volume>
          .
          <string-name>
            <surname>Catania</surname>
          </string-name>
          , Italy: CEUR-WS,
          <year>September 2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>G.</given-names>
            <surname>Pappalardo</surname>
          </string-name>
          and E. Tramontana, “
          <article-title>Suggesting extract class refactoring opportunities by measuring strength of method interactions</article-title>
          ,”
          <source>in Proceedings of Asia Pacific Software Engineering Conference (APSEC)</source>
          . Bangkok, Thailand: IEEE,
          <year>December 2013</year>
          , pp.
          <fpage>105</fpage>
          -
          <lpage>110</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>[16] “http://developer.download.nvidia.com/compute/cuda/4 1/rel/toolkit/docs/online/index.html.”</mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <given-names>W.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Beister</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Kyriakou</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Kachelries</surname>
          </string-name>
          , “
          <article-title>High performance median filtering using commodity graphics hardware</article-title>
          ,
          <source>” in Nuclear Science Symposium Conference Record (NSS/MIC)</source>
          ,
          <year>2009</year>
          IEEE,
          <year>Oct 2009</year>
          , pp.
          <fpage>4142</fpage>
          -
          <lpage>4147</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <string-name>
            <given-names>A.</given-names>
            <surname>Remenyi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Szenasi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I.</given-names>
            <surname>Bandi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Vamossy</surname>
          </string-name>
          , G. Valcz,
          <string-name>
            <given-names>P.</given-names>
            <surname>Bogdanov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Sergyan</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Kozlovszky</surname>
          </string-name>
          , “
          <article-title>Parallel biomedical image processing with gpgpus in cancer research,” in Logistics and Industrial Informatics (LINDI</article-title>
          ),
          <year>2011</year>
          3rd IEEE International Symposium on,
          <source>Aug</source>
          <year>2011</year>
          , pp.
          <fpage>245</fpage>
          -
          <lpage>248</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [19]
          <string-name>
            <given-names>M.</given-names>
            <surname>Kachelriess</surname>
          </string-name>
          , “
          <article-title>Branchless vectorized median filtering</article-title>
          ,
          <source>” in Nuclear Science Symposium Conference Record (NSS/MIC)</source>
          ,
          <year>2009</year>
          IEEE,
          <year>Oct 2009</year>
          , pp.
          <fpage>4099</fpage>
          -
          <lpage>4105</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>