Prakhar Amba

Jérôme Dias

David Alleysson

Random CFAs are better than regular ones

Most of digital cameras today use a color filter array and a single sensor to acquire color information of the scene. In this paper, we ask which arrangement of colors in the mosaic of the color filter array provides the best encoding of the scene. As a solution of the inverse problem of demosaicing, we consider a linear minimum mean squared error model. We used redundancy given by the neighborhood on the sampled image to ensure the stability of the solution. For some CFAs, LMMSE with neighborhood provides equivalent reconstruction results and less variability among the image content compared to edge directed demosaicing on the Bayer. LMMSE allows comparing CFAs of regular pattern with random ones. We show that mosaics with random arrangement of colors and quasi equal proportion of RGB provide best reconstruction performance.

Introduction

A color image is composed with the intensity of three different channels covering three different domains of wavelength, usually in the Red, Green and Blue part of the visible spectrum. To acquire such an image with simplicity and low cost, a single sensor is used which is covered with a color filter array (CFA) to provide several color components to the acquired image, arranged in a mosaic. Thus only a single color is sampled at each pixel and reconstruction of missing colors (called demosaicing or demosaicking) is required. The Bayer's CFA [1] is the most commonly used CFA and several methods have been proposed for improving the quality of the reconstruction. Edge directed [START_REF] Hamilton | Adaptive color plane interpolation in single color electronic camera[END_REF] methods which interpolate along contours and avoid interpolation across them are known to be the best method for the Bayer CFA. These methods are usually followed by a post-processing that improves the reconstructed image [START_REF] Paliy | Spatially Adaptive Color Filter Array Interpolation for Noiseless and Noisy Data[END_REF][START_REF] Hirakawa | Adaptive homogeneity-directed demosaicing algorithm[END_REF][START_REF] Li | Demosaicing by successive approximation[END_REF][START_REF] Menon | Demosaicing with directional filtering and a posteriory decision[END_REF][START_REF] Zhang | Color demosaicking via directional linear minimum mean square-error estimation[END_REF][START_REF] Gunturk | Color plane interpolation using alternating projections[END_REF][START_REF] Malvar | High-quality linear interpolation for demosaicing of Bayer-patterned color images[END_REF][START_REF] Hore | An edge-sensing generic demosaicing algorithm with application to image resampling[END_REF]. But the computation time needed for these methods makes them generally too costly for embedded systems. Moreover in practice, the CFA image produced by a sensor is less constraining than the simulated image on the Kodak database [11] (the most used one on demosaicing) which contains moiré due to higher frequency content compared to the number of pixels. This is even worse for recent cameras with small pixels size [START_REF] Yasuma | Generalized assorted pixel camera: postcapture control of resolution, dynamic range, and spectrum. Image Processing[END_REF]. Because these methods are optimized for Bayer CFA they are not very useful for general CFAs such as those with random arrangement of color.

Some studies show new CFA patterns, but either they are designed empirically [START_REF] Lukac | Color filter arrays: Design and performance analysis[END_REF][START_REF] Yamanaka | Solid State Camera[END_REF][15]. Many authors have proposed optimal CFAs arrangement based on the criteria of frequency representation and selection [START_REF] Condat | A new color filter array with optimal sensing properties[END_REF][START_REF] Hirakawa | Spatio-spectral color filter array design for optimal image recovery[END_REF][START_REF] Bai | Automatic Design of Color Filter Arrays in the Frequency Domain[END_REF][START_REF] Hao | A geometric method for optimal design of color filter arrays[END_REF][START_REF] Couillaud | Nature-inspired colorfilter array for enhancing the quality of images[END_REF]. Indeed, the mosaic arrangement of the filters in the CFA could be interpreted as a spatial multiplexing of color components and has a simple expression in the Fourier domain [START_REF] Alleysson | Color demosaicing by estimating luminance and opponent chromatic signals in the Fourier domain[END_REF][START_REF] Alleysson | Linear demosaicing inspired by the human visual system[END_REF][START_REF] Dubois | Frequency-domain methods for demosaicking of Bayer-sampled color images[END_REF]. The spatial Fourier representation of the CFA allows simple linear demosaicing by selecting the part of the spectrum that corresponds to luminance and color components. Some authors assume the RGB filter's spectral sensitivity can be modified and consider composed colors as a linear combination of RGB and propose an arrangement of these new colors that optimize the frequency representation and estimation. But there is no evidence that these new colors can be easily produced from physical composition of the RGB pigments. Additionally, the simple mathematical expression of spatial multiplexing is due to periodicity or regularity in the mosaic. The locality of chrominance is lost for a random arrangement of color on the CFA. This prevents the application of frequency selection method on random CFAs.

Demosaicing is an inverse problem to retrieve the missing colors from the sampled ones. This kind of problem has no general solution. To solve it, we must consider a model of the solution family (solutions appear as a functional for which a set of parameters are optimal for the problem) and providing the best estimated solution inside this family. It is almost straightforward to consider linear solutions [START_REF] Ribes | Linear inverse problems in imaging[END_REF]. We therefore restrict here the solutions to be linear application from ℝ to ℝ , will be the dimension of the mosaiced image plus neighborhood's space and the dimension of the reconstructed color image's space (See next section for detail on the image formation model).

A general linear approach for demosaicing consists of minimizing the squared error of reconstruction and derives a linear least square approximation of the solution [START_REF] Trussell | A MMSE estimate for demosaicking[END_REF][START_REF] Trussell | Mathematics for demosaicking. Image Processing[END_REF]. This method is general and applies equally well to any CFA. Because most of the CFAs are a replication of a basis pattern, a shift invariant solution can be found, which simplifies calculation by considering only the basis pattern (called super-pixel) replicated on the surface of the CFA, a 2x2 array for Bayer's pattern [START_REF] Trussell | Mathematics for demosaicking. Image Processing[END_REF][START_REF] Taubman | Generalized wiener reconstruction of images from colour sensor data using a scale invariant prior[END_REF]. Despite the generality of the method which allows optimizations [START_REF] Parmar | A perceptually based design methodology for color filter arrays [image reconstruction[END_REF][START_REF] Parmar | Selection of optimal spectral sensitivity functions for color filter arrays[END_REF][START_REF] Parmar | Selection of optimal spectral sensitivity functions for color filter arrays[END_REF], the solution obtained with such a procedure is unstable because the number of unknowns is larger than the number of inputs. An elegant way for improving the number of inputs is to consider a closed neighborhood around the position to be interpolated. Intuitively, this reinforces the statistical learning of the solution with existing data and provides good reconstruction results [START_REF] De Lavarène | Practical implementation of LMMSE demosaicing using luminance and chrominance spaces[END_REF][START_REF] Alleysson | Linear minimum mean square error demosaicking. Single-sensor imaging: Methods and applications for digital cameras[END_REF][START_REF] Lu | Optimal color filter array design: Quantitative conditions and an efficient search procedure[END_REF][START_REF] Lu | Designing color filter arrays for the joint capture of visible and near-infrared images[END_REF][START_REF] Sadeghipoor | Correlation-based joint acquisition and demosaicing of visible and near-infrared images[END_REF][START_REF] Sadeghipoor | Optimum spectral sensitivity functions for single sensor color imaging[END_REF]. This framework allows the use of a random pattern inside the super-pixel [START_REF] Alleysson | Frequency selection demosaicking: A review and a look ahead[END_REF] even if the spatial frequency spectrum of luminance and chrominance for these CFAs is aliased.

Based on the LMMSE demosaicing we can directly compare, over a similar reconstruction method, the performance of any CFA pattern to reconstruct the desired image from the acquired image. In the next section we describe the formalism for demosaicing with linear minimum mean square error, learning over a database with generalized neighborhood. We then compare the performance of several CFAs. We also show the comparative performance with some of the state of the art methods applying on Bayer CFA.

Linear model of image formation

Writing a matrix model of image formation requires unfolding the matrix representing images into vectors, then finding a matrixvector multiplication that relates the expected image from the acquired one [START_REF] Trussell | Mathematics for demosaicking. Image Processing[END_REF]. In the case of demosaicing we suppose that the mosaiced image results from a color image multiplied by a projection matrix [START_REF] Alleysson | Linear minimum mean square error demosaicking. Single-sensor imaging: Methods and applications for digital cameras[END_REF]. But there are many ways of unfolding images that results in different models.

Classically an image is unfolded into a column vector. For the demosaicing problem it is expressed as follows: consider a color image having H rows, W columns and P color channels and the mosaiced image having H rows and W columns. We can construct the column vector of size 1 corresponding to the color image and of size 1 corresponding to the mosaiced image [START_REF] Trussell | Mathematics for demosaicking. Image Processing[END_REF]. In this case the model of image formation can be expressed as: (1) where is a matrix that transforms the vector corresponding to a color image into a vector corresponding to the mosaiced image.

The demosaicing matrix , we wish to estimate is the reverse operator that gives the estimate ^ from . It can be calculated from several couples , constructed from a database with the Wiener filtering approach that corresponds to the least square error estimator.

such that ^ ,

.. ! (2)
With .. ! is the expectation over the " images of the database. In this model is of size . This model implies huge matrices as a model because the dimension of or is of size of the number of pixels in the images. A better model is given by considering the block shift invariant property of the mosaic. Since the mosaic is composed by a super-pixel of size # $ replicated on the whole CFA of size , we can unfold the image for #$ instead of . In this case the model formulation (equation 1) remains the same but is now a #$ #$ ⁄ matrix containing the set of vectors built from one super-pixel in the color image. And is a #$ #$ ⁄ matrix corresponding to the set of vectors built from one super-pixel of the mosaiced image. Thus is a #$ #$ matrix (i.e. 4x12 for the 2x2 super-pixel of the Bayer CFA) and is a #$ #$ matrix [START_REF] De Lavarène | Practical implementation of LMMSE demosaicing using luminance and chrominance spaces[END_REF][START_REF] Alleysson | Linear minimum mean square error demosaicking. Single-sensor imaging: Methods and applications for digital cameras[END_REF] which greatly reduces the computational complexity required to calculate and apply the reconstruction to the acquired data. But, with this model, the number of values to be retrieved is times larger than the acquired values making the estimate quite unstable.

To reinforce the stability of the solution, a neighborhood of could be used. Let's be a vector built from and its close neighborhood of size & ' , ( ) , * . ( ) , * . is a function that increase the number of rows of a vector by the & ' neighbors of each element of the vector. In this case, is of size

#$ & ' #$ ⁄
and the number of rows of could be easily larger than #$.

In this later unfolding, the computation of the demosaicing matrix from couples , constructed from the database is given by the following equation:

such that ^ , .. ! (3)
Similarly to the equation 1, it is possible to design a matrix that transform a neighborhood in the color image (vector ) into a neighborhood of the mosaiced image , i.e.

. It is also possible to design a matrix + that transform the vector into the vector , i.e.

+ , such that it suppresses the neighborhood and selects the central pattern. With these two matrices, can be expressed as:

+ , , , with , ! (4)
Equation 4 implies that we need to calculate the correlation , only once from the color images with their neighborhoods in the database. Then, for a particular CFA into consideration, we can construct and + and compute the optimal demosaicing filter in the least square sense. Thus, with the same , we can compare the performance of any CFA.

In [START_REF] Lu | Optimal color filter array design: Quantitative conditions and an efficient search procedure[END_REF], a similar notation to Equation 4 is provided, but the neighborhood size is restricted to an integer number of the size of the super-pixel which becomes intractable when super-pixel size increase and is less flexible. Here, we proposed a generalization for any CFA with any super-pixel size and any arrangement of colors inside the super-pixel. The construction of and + for a particular arrangement and a particular neighborhood is not trivial and cannot be described more here.

Simulation

With the framework given in the previous section, we can easily compare the performance of several CFAs with any superpixel size and any arrangement of colors inside the super-pixel as well as any size of the neighborhood used for controlling redundancy. The framework works as follows: for any color image taken from the database, we compute , composed by the set of vectors constructed for every pixel inside the super-pixels and theirs neighbors. From all taken from all images in the database, we compute , according to Equation 4. Then we design + and for the CFA and the neighborhood size. We compute D with Equation 4.

The performance of the demosaicing is then computed as follows: for each image in the database, we compute the mosaiced image by subsampling the color image according to the CFA. Then we compute the vector using the neighborhood. We apply D on as in Equation 3 to reconstruct the estimate ^ and compare it to by calculating PSNR (A border equivalent to neighborhood size was removed in the calculation).

We compute a PSNR from the whole mean square difference between the original and reconstructed image for all pixels and three PSNRs, one per color channel. We use the average of whole PSNR over all the images in the database,as an estimator of the overall quality of the reconstruction. The variance of the whole PSNR along image number, . gives an estimate of the adequacy of the method to encode any particular image. To test the method to equally encode any colors, we used the average of the PSNR per channel, -/ , -0 and -1 as well as the average of the variance of PSNR per channel, . /01 . Finally, the SSIM [START_REF] Zhou | Image Qualifty Assessment: From Error Visibility to Structural Similarity[END_REF] (computed the three channels together) is also provided to estimate the quality of the image in term of visual factors.

We perform the analysis on two databases (Kodak [11], McM [START_REF] Zhang | Color demosaicking by local directional interpolation and nonlocal adaptive thresholding[END_REF]) for comparing the performances. The Kodak database is known to have much higher frequency compared to the number of pixels and with low colorfulness which favor the edge directed and postprocessing methods. The McM database has been proposed has having more realist images in term of high frequency and colorfulness. We generally used all the images from the database for learning the demosaicing operator. We also implement a leaveone-out simulation where the image to reconstruct is not in the set of images used to learn which are presented in supplementary material [42].

Systematic evaluation for 2x2, 3x3 super-pixel size of the CFA

As a first example of performance comparison, we consider all the different combination of three colors R, G, B on a 2x2 super-pixel. The number of different possible arrangements is 3 4 = 81. Notice however that a lot of them are symmetrical than others. We also consider all the different combinations of the 3x3 superpixel, there are 3 3 19683 different ones.

Table 1 and Figure 3 (top row) shows the best 2x2 arrangements calculated over the Kodak databases. In term of average PSNR, -, the best arrangement is not the Bayer RG;GB but slightly modified one where the arrangement is RG;BG (2x2 #1). If we look at the average variance between PSNR calculated on individual color channels in the reconstructed images over the database, . /01 , the best is RB;GB (2x2 #2) arrangement. Also, if we look at the average variance of the overall PSNR, ., along all the images in the database, the BR;GG (2x2 #3) is the best. This shows the following criterion that either twice of green or blue is preferred but the color represented twice is never on the diagonal.

Table 1 and Figure 3 (top row) also shows the result for evaluating all the different 3x3 CFAs. Again depending on the criterion (-, . /01 , . three different optimal ones are shown. Among these three no one is regular and all three show an almost equal number of RGB.

Figure 2 shows the histogram of the average PSNR, -, for all of 3x3 CFAs. The three first peaks correspond to CFA with only one or two colors. A shown in Figure 2 (b), among the best hundred 3x3 CFAs, some are symmetrical but none are perfectly regular.

Comparison of CFAs under LMMSE

We select several CFAs (Figure 3) proposed in the literature that we have tested with LMMSE demosaicing. We also compute the best arrangement of the 4x4 (they are 3^16 > 43 Millions) by pruning those with high bias between colors based on the previous results for 3x3 and 2x2. We also add the best 2x2 and the original Bayer in the comparison. Figure 4 shows the performance of CFAs along the neighborhood size. Which clearly favor the best 4x4 #2 for a neighborhood of size larger than 3. This CFA is also performing well with variance estimators showing its ability to equally encode colors and perform well for any image in the database. [START_REF] Yamanaka | Solid State Camera[END_REF], Lukac [START_REF] Lukac | Color filter arrays: Design and performance analysis[END_REF], Holladay halftone [START_REF] Parmar | Selection of optimal spectral sensitivity functions for color filter arrays[END_REF], CNRS [15]. Table 1 shows the number of the evaluation parameter estimated based on a neighborhood of 10x10 for the CFAs. In the table we highlight the number that is the best within that category. For example the best 2x2 for average PSNR,is given for the 2x2 #1. We show the result for the 4x4 #1 because even if it is not the best for average PSNR, it has very good visual performance on the fence of the lighthouse image as show in the supplementary material [42].

, 2x2 #1, 2x2#2, 2x2#3, 3x3#1, 3x3#2 3x3 #3, bottom row, 4x4 #1, 4x4 #2, Yamanaka

Comparison with other methods on Bayer

We compare the best 4x4 using a neighborhood of 10 with the state of the art method applying on the Bayer CFA using both the 2 shows the evaluation parameters as well as the computation time on Matlab. The code for the algorithms is found on web site [41]. [START_REF] Paliy | Spatially Adaptive Color Filter Array Interpolation for Noiseless and Noisy Data[END_REF], LIAN [START_REF] Lian | Adaptive Filtering for Color Filter Array Demosaicking[END_REF], DA [START_REF] Alleysson | Color demosaicing by estimating luminance and opponent chromatic signals in the Fourier domain[END_REF], HD [START_REF] Hirakawa | Adaptive homogeneity-directed demosaicing algorithm[END_REF], SA [START_REF] Li | Demosaicing by successive approximation[END_REF], DFPD [START_REF] Menon | Demosaicing with directional filtering and a posteriory decision[END_REF], DLMMSE [START_REF] Zhang | Color demosaicking via directional linear minimum mean square-error estimation[END_REF], AP [START_REF] Gunturk | Color plane interpolation using alternating projections[END_REF], LI [START_REF] Malvar | High-quality linear interpolation for demosaicing of Bayer-patterned color images[END_REF], HA [START_REF] Hamilton | Adaptive color plane interpolation in single color electronic camera[END_REF] are tested with a border of 15, 4x4 #1 and 4x4 #2 reported with a border of 10.

For the Kodak database, the best 4x4 has almost the same performance as the best edge directed method with a far less variance between colors. It has also a better variance among images on the database as well as SSIM [START_REF] Zhou | Image Qualifty Assessment: From Error Visibility to Structural Similarity[END_REF] and computation time per image. For the MCM database, the best 4x4 under LMMSE perform better than any other in the test for almost all these performance parameters. Supplementary material [42] shows some examples of reconstruction based on particular area on images.

For sure the extent of the size of the super-pixel provides a better encoding of the scene as shown by the objective criteria such the PSNR. But in our simulations, we also see that the random arrangement of colors in the CFA also reduces the visibility of the noise generated by the mosaicing/demosaicing process because noise becomes less structured.

Conclusion

In this paper we provide a flexible, fast and accurate linear minimum mean squared error demosaicing using the redundancy given by the neighborhood of the sampled image. The method is quite fast and allows us to systematically compare the performance of 2x2 and 3x3 CFA's super-pixels and most of the 4x4 CFAs.

Compared to frequency selection approaches used today for optimizing CFAs, our method does not guess the frequency spectrum of the sampled image by the CFA. Rather, it uses a learning procedure that computes optimal reconstruction filters. Even when the aliasing between luminance and chrominance is strong (as arising for random pattern), the method find good linear reconstruction filters. We found that the best CFAs are the ones with non-regular arrangement of colors (some are symmetric along the +-45° line) and almost equal number of RGB.

The best known methods for demosaicing are thought to be those with edge directed interpolation and post processing. We show that the 4x4 best CFAs give reconstruction results equivalent to the best nonlinear algorithms applied on Bayer. It even provides less variability among colors and particular image in the database. Moreover it gives better SSIM evaluation for a less computation time. This result provides linear demosaicing for being favorably used in the embedded camera devices.

Statistics of natural images are probably random because a contour or a particular object's color could potentially appear anywhere on the images. That is probably why random CFA perform better than regular one for encoding the spatial and chromatic structure of natural images.

Figure 1 :

 1 Detail of the unfolding of images into vectors (a) Mosaiced image ICFA with a neighborhood shown (b) Unfolding of the mosaiced image into matrix x1 (c) Color image I (d) Unfolding of the color image into matrix y.

Figure 2 :

 2 Figure 2: (a) Histogram of the PSNR for all 3x3 CFAs. A large number of them show more than 38dB of average PSNR. (b) The top hundred 3x3 CFA's for average PSNR learned over the Kodak database (The PSNR ranges between 38.96 and 38.70 for the top hundred for neighborhood of 10 for Kodak database). See supplementary material for the result on McM [42].

Figure 3 :

 3 Figure 3: Different CFA pattern used for comparison. From left to right top row, Bayer, 2x2 #1, 2x2#2, 2x2#3, 3x3#1, 3x3#2 3x3 #3, bottom row, 4x4 #1, 4x4 #2, Yamanaka[START_REF] Yamanaka | Solid State Camera[END_REF], Lukac[START_REF] Lukac | Color filter arrays: Design and performance analysis[END_REF], Holladay halftone[START_REF] Parmar | Selection of optimal spectral sensitivity functions for color filter arrays[END_REF], CNRS[15].

Figure 4 :

 4 Figure 4 : Evaluation of CFAs with LMMSE with increasing neighborhood (a) Average PSNR, -. (b)Variance of PSNR per channel, . /01 . (c) Variance of PSNR with image number, ..

9

  Comparison of CFA, σ plotted for Kodak database Neighbourhood size σ Kodak and McM database. The following Table

Table 1 : Comparison of CFA for Kodak database, nh = nw = 10

 1

	CFA				Kodak
		μ	8 9	8 :	8 ;	< 9:;	σ	SSIM
	Bayer	38.90 38.57 41.53 37.59	4.64 6.57 0.9911
	2x2 #1	39.51 39.41 40.36 38.99	1.01 7.21 0.9923
	2x2 #2	39.10 38.71 39.39 39.32	0.53 7.64 0.9917
	2x2 #3	39.12 38.27 40.27 39.22	1.78 5.01 0.9916
	3x3 #1	37.16 37.40 37.13 37.02	0.22 6.34 0.9881
	3x3 #2	38.96 38.70 39.48 38.78	0.39 6.81 0.9913
	3x3 #3	36.36 37.40 35.81 36.13	1.11 5.41 0.9859
	4x4 #1	40.26 40.51 40.32 40.05	0.40 6.44 0.9933
	4x4 #2	40.40 41.00 39.82 40.56	0.76 6.39 0.9936
	Yaman.	38.73 37.82 40.95 38.19	3.46 6.81 0.9910
	Lukac	39.35 38.70 41.47 38.57	3.13 6.31 0.9918
	Holladay	38.57 39.23 39.62 37.30	1.87 6.05 0.9908
	Cnrs	39.78 40.01 40.02 39.39	0.40 6.42 0.9927

Table 2 : Comparison between the best 4x4 with LMMSE on Kodak database and other methods.

 2

					Kodak
	Method	μ	8 9	8 :	8 ; < 9:;	σ	SSIM	Time (s)
	4x4 #1	40.26 40.51 40.32 40.05 0.40 6.44	0.9933	0.64
	4x4 #2	40.40 41.0 39.82 40.6 0.76 6.39	0.9936	0.65
	LPA-ICI	40.52 39.63 43.0 39.91 4.45 7.08	0.9874	1.15
	LIAN	39.53 38.59 42.13 38.86 4.63 7.39	0.9855	0.31
	DA	37.82 37.38 40.66 36.54 5.27 5.82	0.9829	0.09
	HD	37.72 36.94 39.59 37.26 2.82 8.64	0.9799 28.11
	SA	39.01 37.92 41.56 38.53 4.57 6.37	0.9850	1.30
	DFPD	39.17 38.32 41.23 38.70 3.25 7.83	0.9837	1.55
	DLMMSE 40.05 39.12 42.58 39.53 4.79 6.92	0.9866 28.84
	AP	39.25 38.29 41.73 38.70 4.40 6.07	0.9849	1.61
	LI	35.66 35.16 38.83 34.25 6.05 10.24	0.9729	0.02
	HA	36.87 36.75 38.05 36.08 1.20 10.40	0.9769	0.08
	Bilinear	30.19 29.25 33.07 29.26 4.94 10.94	0.9160	0.04

Table 3 : Comparison between the best 4x4 with LMMSE on McM database and other methods.

 3

					McM
	Method	μ	8 9	8 :	8 ; < 9:;	σ	SSIM	Time (s)
	4x4 #1	35.44 36.96 35.89 34.14 2.83 9.32	0.9832	0.39
	4x4 #2	35.96 37.3 35.55 35.4 1.84 9.33	0.9851	0.40
	LPA-ICI	34.70 34.32 37.88 33.29 6.62 13.20	0.9655	0.64
	LIAN	34.91 34.55 37.95 33.52 6.13 10.40	0.9673	0.17
	DA	32.22 31.82 34.69 31.07 4.16 13.33	0.9528	0.06
	HD	33.46 32.94 36.96 32.15 7.94 11.20	0.9576 18.50
	SA	32.69 32.56 34.42 31.70 2.71 17.88	0.9529	0.87
	DFPD	34.22 33.74 37.17 32.96 5.64 10.77	0.9624	0.99
	DLMMSE 34.43 33.97 37.9 33.02 7.93 11.21	0.9647 18.27
	AP	33.14 32.79 35.13 32.17 3.01 12.47	0.9567	1.03
	LI	34.39 33.94 37.52 32.97 6.03 8.75	0.9645	0.02
	HA	34.79 34.58 37.9 33.27 6.87 9.96	0.9654	0.05
	Bilinear	32.29 31.65 35.38 31.20 6.59 11.58	0.9487	0.03
	LPA-ICI

Acknowledgment

This work is financed by the FUI Extrem OWL no. F1411026U to P. Amba and D. Alleysson.

Author Biography


Yifan Li
email: yifan.li@lip6.fr

Scalable Approaches for Recommendation in Social Networks

Keywords: Social Network, Recommendation System, Graph, Pregel, Personalized PageRank

, the social affinity among users can provide more precision in recommendation result(scores) calculation.

In this doctoral thesis, we propose to design a scalable recommendation approach over large social graph, taking into consideration not only graph topological properties but also those user semantic content, e.g. user interest, (hash-)tags, item ratings, to gain a good and fast recommendation evaluation.

INTRODUCTION

Social network, e.g. Facebook, Linkedin and Weibo, as a new but sharply growing media, has permeated our lives. For instance, by April 2014, the main micro-blogging service in the world, Twitter, has build a social graph consisting of more than 570 million users. Moreover, around one million new accounts are registered in Twitter every week, and 500 million fresh tweets are posted every day. Hence, this rapidly increasing data volume and natural structure dynamism present twofold serious challenges to our existing data management system, 1) distributed graph storage and computation and 2) scalable algorithm performing.

To deal with the first problem: most of social graphs are too large to fit in memory and disk on a generic machine, sev- * supervised by Prof. Cedric du Mouza(CNAM, Paris) and Prof. Camelia Constantin(LIP6-UPMC, Paris) eral distributed graph computation models, such as Pregel [START_REF] Malewicz | Pregel: A system for large-scale graph processing[END_REF], PowerGraph [START_REF] Gonzalez | Powergraph: Distributed graph-parallel computation on natural graphs[END_REF], GraphX [START_REF] Xin | Graphx: A resilient distributed graph system on spark[END_REF], have been proposed to meet this requirement. The graph partitioning strategy study, however, has not been fully conducted in these systems in which it is indeed the basis for distribution. For this reason, our first task is to propose an efficient flexible partitioning approach for processing large social graphs in a distributed way, in stead of a simple hash function method with high communication cost.

For answering the query for a given node in social graph, we need to evaluate the calculation of topological similarity between two nodes in graph. Whereas the volume of the social network and its dramatical growth raise scalability issue. However these existing graph algorithms don't give sufficient weight on either increasing computation parallelism or exploring topological feature inside graph partition. Thus, in my thesis we plan to propose an segments-based similarity computation algorithms that can be implemented on large scale graph processing systems that offer transparent scalability, high computation parallelism and fully using of graph partitioning feature.

SCALABLE GRAPH PROCESSING

Graph Partitioning

Naturally, how to partition a social network is the foundation of a distributed graph processing system. Given a graph application, the partitioning strategy has a huge impact on its performance. From perspective of querying, a good graph partitioning also can advance the query evaluation in a data/computation-distributed context.

Hence, here we proposed a novel workload-aware Blockbased Partitioning Strategy to acquire targets: 1) Minimised Communication, 2) Balanced Workload Block Construction using Seeds. In this thesis, a block can be seen as one, or part of tightly knit cluster in graph, e.g. a community in social network, which is formed by several edges, rather than vertices. We propose to find those K inherent blocks B1, B2, ..., BK from graph G by exploring its full potential topology. Especially, there are K pre-selected seed vertices, of which one is per block as its centre. Then we compute the closenesses, from seeds, to the two nodes of every edge, which will be used to determine the ownership of edge finally.

Closeness between Nodes. Since the block an edge belongs is determined by the closeness(namely reachability) from its seed(center) to that edge's two end-nodes. Firstly we propose to offer a method to measure that closeness, by using a simpler inverse P-distance:

Di(j) ≡ p∈{i∼j} S(p)
where the p is a path from node i to node j or vice versa, which is formed by a sequence of edges. S(p) is the inverse distance value of path p: v0, v1, ..., v (k-1) with length k, and is defined as

S(p) = (1 -α) k • k-1 i=0 1 outDeg(vi)
where α ∈ (0, 1)is the teleporting probability in the random walk, which means the probability to return origin. outDeg(vi) is the out-degree of vertex vi.

Edge Allocation. For each edge triplet, we will calculate the two closeness-score vectors together to obtain the final result: the block(seed) id it belongs.

Block Refinement. Due to the limits for workload balancing, or computation balancing further, we need to conduct some kind of necessary refinement operations on blocks, e.g. to combine several small ones or split a large one.

Demostration. Up to now, from our existing experiments, the communication measurement [START_REF] Gonzalez | Powergraph: Distributed graph-parallel computation on natural graphs[END_REF], vertex replication factor, has been reduced to around 40 percent, and it has also cut the graph processing time in half, compared with the EdgePartition2D in [START_REF] Xin | Graphx: A resilient distributed graph system on spark[END_REF] which has best performance generally. Then, we tend to perform more experiments to observe boundary-crossed communication between partitions, esp. for our segments-based algorithm.

In addition, we will further give a fresh analysis on computation balancing, rather than storage balancing, for the first time.

Scalable Similarity Algorithm

The main target for recommendation on a social network is to find the most similar node(s) for a given node. This task can be considered from two aspects: 1) searching the topologically close node(s) and 2) searching the semanticclose node(s).

Among those existing graph-based similarity computation algorithms, e.g. Hitting Time, PageRank, Graph Distance, we made an adapted segments-based Monte Carlo method to approximate Fully Personalized PageRank(PPR) to measure the topological similarity between nodes [START_REF] Avrachenkov | Monte carlo methods in pagerank computation: When one iteration is sufficient[END_REF][START_REF] Jeh | Scaling personalized web search[END_REF].

Here, as the ideas in [START_REF] Fogaras | Towards scaling fully personalized pagerank[END_REF][START_REF] Sarma | Estimating pagerank on graph streams[END_REF], instead of simulating a complete long random walk over the whole graph, several short walks(of lengths geometrically distributed on teleporting factor) are conducted starting from the common node. Finally the approximate PPR value can be obtained by counting the frequencies of visits to each node in short walks. Especially, still, each short random walk can be divided into shorter segments, thus in this way we can increase the parallelism of graph computation which is implemented in Pregel model. Moreover, the considerable short segments(random walk) starting from the same initial node are expected to stay in a common graph partition.

FUTURE WORK

Seeds Selection Strategy

The quality of seeds has a big effect on graph partitioning result, for this reason, we need to make more effort to seek out a way for adaptive seed selection with various graph topologies.

Personalized PageRank

We have had a straight-forward segments-based random walk simulation algorithm that can be applied to PPR easily, but nonetheless, more optimisations, w.r.t Pregel computation model, are still worthwhile.

Graph Evolving

The dynamism is another big challenge in computing large graphs of real world, social network etc. We plan to extend the recommendation model to deal with the change of social network structure and user content, with necessary but acceptable additional cost.

  (c) 2015, Copyright is with the authors. Published in the Proceedings of the BDA 2015 Conference (September 29-October 2, 2015, Ile de Porquerolles, France). Distribution of this paper is permitted under the terms of the Creative Commons license CC-by-nc-nd 4.0. (c) 2015, Droits restant aux auteurs. Publié dans les actes de la conférence BDA 2015 (29 Septembre-02 Octobre 2015, Ile de Porquerolles, France). Redistribution de cet article autorisée selon les termes de la licence Creative Commons CC-by-nc-nd 4.0. BDA 29 September 2015, Porquerolles, France.


Roberto Morabito

Riccardo Petrolo

Valeria Loscrí

Nathalie Mitton

Enabling a lightweight Edge Gateway-as-a-Service for the Internet of Things

Keywords: Internet of Things, Edge Computing, Virtualization, Gateway, Container

Since its introduction, the Internet of Things (IoT) has changed several aspects of our lives, leading to the commercialization of different heterogeneous devices. In order to bridge the gap among these heterogeneous devices, in some of the most common IoT use cases -e.g., smart home, smart buildings, etc.the presence of a gateway as an enabler of interoperability is required. In this paper, we introduce the concept of a Gateway-asa-Service (GaaS), a lightweight device that can be shared between different users thanks to the use of virtualization techniques. Performance has been evaluated on real hardware and results demonstrate the lightweight characteristics of the proposal.

I. INTRODUCTION

The Internet of Things (IoT) is signing an important revolution in all the aspects of our lives, i.e., health, transportation, work, and so on and so forth. The tremendous interest behind the IoT has led to the development and commercialization of different types of devices -billions are already deployed, and the number will reach 50 billion by 2020 according to [START_REF] Evans | The Internet of Things -How the Next Evolution of the Internet is Changing Everything[END_REF]-. These objects are often designed in order to better suit specific application needs; therefore by using various technologies in terms of hardware and network protocols. As a result, nowadays, we have a proliferation of heterogeneous things and standards that has brought to a fragmented and complex landscape. To bridge this gap, an interesting and promising approach is to apply semantic technologies -already well spread in the Web-as an enabler of interoperability among heterogeneous devices [START_REF] Petrolo | Towards a Smart City based on Cloud of Things, a survey on the smart city vision and paradigms[END_REF].

In some IoT contexts -such as smart home, smart buildings, smart farms, and so on and so forth-the interoperability among disparate devices can be achieved at the gateway. In [START_REF] Petrolo | The design of the gateway for the cloud of things[END_REF] we proposed the architecture of a gateway capable to manage, on one hand, semantic-like things and, on the other hand, to act as an end-point for the presentation of data to users. In this paper, we introduce the concept of Gateway-as-a-Service (GaaS), as an efficient and lightweight device, which can be shared between different users. Thanks to emerging lightweight virtualization techniques, indeed, it is possible to provide high versatility and customizability to the platform. The proposal has been implemented on real hardware, and validated through an extensive performance evaluation.

The remainder of the paper is organized as follows. Section II explores related work. In Section III, we introduce the main characteristics of our Gateway-as-a-Service, while Section IV focuses on the performance evaluation and in particular the impact of using virtualization technologies in our solution. Section V concludes the paper.

II. RELATED WORK

In this section, we discuss related work linked to our proposal; we first analyze initiatives regarding the interoperability in the Internet of Things; then, we focus on the literature proposing solutions in which virtualization technologies are employed at the network edge.

As stated by Desai et al. in [START_REF] Desai | Semantic gateway as a service architecture for iot interoperability[END_REF], a scalable IoT architecture should be independent from messaging protocol standards, while also providing integration and translation between various popular messaging protocols. Recently, semantic techniques started to became popular also in the IoT context [START_REF] Petrolo | Towards a Smart City based on Cloud of Things, a survey on the smart city vision and paradigms[END_REF], as an enabler of the interoperability among disparate devices. Authors in [START_REF] Desai | Semantic gateway as a service architecture for iot interoperability[END_REF] describe a semantic IoT architecture where the gateway, located between physical level sensors and cloudbase services, provides translation between widely used CoAP, MQTT, and XMPP protocols; however authors do not focus on the interactions of the gateway with external users. Wu et al. in [START_REF] Wu | Gateway as a service: A cloud computing framework for web of things[END_REF] propose the concept of Gateway-as-a-Service as a device that provides distributed cloud services for intelligent IoT applications based on the Web of Things (WoT). However, this solution does not consider the heterogeneity of different devices.

Bukhary et al. in [START_REF] Ismail | Evaluation of docker as edge computing platform[END_REF] evaluate Docker container technology as a platform for Edge Computing. In this work, Docker has been evaluated in terms of deployment and termination, resource and service management, fault tolerance and caching. Authors' conclusions are that Docker represents a good solution to be employed in edge computing contexts. In our previous work [START_REF] Petrolo | The design of the gateway for the cloud of things[END_REF], we include lightweight virtualization technologies in the design of a gateway for the Cloud of Things (IoT). In this work, the aforementioned idea is enhanced by introducing new features and an extensive performance evaluation. In [START_REF] Morabito | Enabling data processing at the network edge through lightweight virtualization technologies[END_REF], the design of an IoT gateway that can be efficiently employed also in an edge computing architecture has been proposed. In particular, that study shows how to efficiently and flexibly use Docker containers in order to customize the IoT platform, by offering data processing services. Container technologies are also used in a Capillary Network scenario [START_REF] Novo | Capillary networks -bridging the cellular and iot worlds[END_REF], where Docker containers allow to package, deploy, and execute different functionality at the capillary gateway.

The aforementioned proposals strengthen our vision towards the implementation of an efficient and lightweight gateway for the Internet of Things. Thanks to the use of virtualization techniques, the gateway can be shared among different users and customized according to the use case needs.

III. GATEWAY-AS-A-SERVICE

The architecture of our Lightweight Edge Gateway-asa-Service is depicted in Figure 1. The platform has been designed to meet specific requirements: (i) interoperability; (ii) high energy-efficiency; (iii) fast allocation and flexibility in managing different services; (iv) isolation; (v) backup capabilities; (vi) multitenancy. In the following subsections, each key component is described in detail.

A. Hardware and Operating System

ARM architecture is constantly becoming more widespread by virtue of its low-power characteristics and costs [START_REF] Smith | ARM and Intel battle over the mobile chip's future[END_REF]. The Single Board Computer family Raspberry Pi (RPi) takes advantage of these features, and it became popular, over the last few years, thanks to the different purposes of use; the RPi finds room also in the IoT context, especially for providing gateway functionality [START_REF] Petrolo | The design of the gateway for the cloud of things[END_REF].

In this paper, we selected the last two generations of the Raspberry Pi1 , the Raspberry Pi 2 (RPi2) model B2 and the Raspberry Pi 3 (RPi3) model B 3 , that has been released in February 2016. The main hardware characteristics of the two boards are summarized in Table I.

B. Container Virtualization Technology

According to some of the requirements listed at the beginning of this section, introducing lightweight virtualization technologies allows a system that benefits of interesting features such as: (i) fast building process, instantiation, and initialization of containers; (ii) high density of application/services due to the small container image; (iii) isolation between different instances. This is mainly due to the lightweight characteristics of container technologies if compared to alternative solutions such as hypervisor-based virtualization. The main difference between these two technologies are widely discussed in [START_REF] Morabito | Hypervisors vs. lightweight virtualization: a performance comparison[END_REF]. In our implementation, we use Docker5 containers for executing the different instances. Docker introduces an underlying container engine, together with a functional API that allows easily building, management, and removal of a virtualized application. Docker version 1.11.0 has been used.

C. Application Components

As can be observed in Figure 1, from the application point of view, our architecture is characterized by three main components: (i) a web server that exposes services to the Internet -we chose WildFly6 , an application server written in Java, which runs on multiple platforms; (ii) a search server in which all sensor data is stored -in our design we use Elasticsearch 7 , which provides a distributed search engine with an HTTP web interface and schema-free JSON documents; (iii) an orchestrator that ensures and manages communication paths between all containers. These three main components are virtualized by means of Docker containers; ensuring therefore an isolated environment together with many other benefits that will be clearer from the analysis of the different interactions that the gateway can perform with the rest of the network. Ensuring isolation at the gateway allows also a multitenant platform that can be shared between different users (Fig. 2). This characteristic turns out to be particularly useful in contexts in which the gateway has to keep the peculiarity of being a vendor-independent platform.

Finally, the flexibility given by the use of containers enlarges the potentialities of our platform in terms of backup functionality and capacity of storing the network status at given times.

Another main feature introduced in our gateway design is the On-demand activation of Docker containers, by means of a socket-activation framework. Figure 3 shows a practical use of this component. A remote user forwards the socket activation connection, which then goes through the proxy for activating the web server container. After the activation, the container can receive traffic from the sensors through the proxy. The example refers, in particular, to the activation of the web server container but it can be extended to the rest of the other containers. The implementation of the socket-activation framework allows a dynamic allocation of services in the gateway that can bring several benefits, for example in terms of energy efficiency. Indeed, the container instances can be dynamically allocated only when required, without being constantly active.

A subset of possible interactions that our gateway can keep with other network entities such as Remote Users and Sensors are detailed below.

For example, we want to analyze the simple case of a sensor that transmits its updated parameters to the gateway (Fig. 4a). We assume that the database container was previously activated by a remote user, and that the database containing the latest update data is stored within a cover Docker image. When the gateway receives updated information from the sensor, a Docker container is launched -via the socket/proxy activation-and the new values are stored into the database. Once this transaction is completed, the updated Docker image is saved locally in the gateway. The second interaction (Fig. 4b) can be considered consequently to the first. In this case a remote user aims to access data stored in the database. In this scenario, the user can easily download the latest updated Docker image -which is stored on the gatewayand then have access to data -this case is marked with 1 in the Figure 4b-. However, data can be read directly on the gateway from the Database Docker image. The last interaction (Fig. 4c) describes the case in which the gateway acts as a interface between remote users and sensors. In this case, we can consider the scenario of a user that wants to know the temperature measured in the "Room 105". In this particular case, thanks to the semantic annotation, the gateway knows the best node that can provide the information, then it forwards the request to the specific node.

IV. PERFORMANCE EVALUATION

The validation of our proposal covers two different aspects. First, we evaluate how a Raspberry Pi reacts -in terms of performance-to specific workloads generated by applications running within Docker containers. This is done with the aim to understand the impact of introducing virtualization on the aforementioned hardware. Then, we present a first performance evaluation of our gateway platform while performing specific tasks.

A. General Performance

To challenge specific hardware segments, in both the RPi2 and RPi3, we use software tools capable to generate different types of workloads. In order to estimate the overhead produced by the presence of a single or multiple containers running, we test CPU, Memory, Disk I/O, and Network I/O performance. The native performance -i.e. running the benchmark tool without including any virtualization layer-is used as a reference for comparison. Considering that in our gateway multiple functions are virtualized, by means of containers, our objective is to test the performance when concurrent (virtualized) instances are running.

We test CPU performance with sysbench8 . It executes a stress test designed to challenge the CPU by calculating prime numbers. The performance metric is the execution time (measured in seconds) -a lower execution time implies better performance-. Figure 5a shows the results coming from this test when up to four concurrent instances -native and virtualized-are running. We can mainly observe that the container engine introduces a negligible impact on the CPU performance in each single case. From the power consumption perspective, we can notice that the consumption of RPi3 is slightly higher compared to RPi2.

We use the Unix command mbw9 to test the Memory I/O performance. The benchmark tool determines the available memory bandwidth by copying large arrays of data in memory, and performing three different tests (memcpy, dumb, and mcblock). Similarly to the previous case, native and container performance can be considered comparable (Figure 5b). RPi3 performance are approximately a third higher compared to the RPi2, at the expense of a minimal increase in the power consumption.

The benchmark tool fio10 has been used in order to evaluate the Disk I/O performance. In particular, the test consists in performing sequential read/write operations against a 6GB file stored on the MicroSD card. Figure 5c shows sequential read and write performance averaged over 60 seconds using a typical 1 MB I/O block size. Docker introduces negligible overhead during the sequential read test. Both Raspberry Pi boards introduce a relevant overhead during the sequential write test almost 50% for RPi2 and 37% for RPi3.

For the Network I/O analysis (Fig. 5d), we want to quantify the power consumption of the two Raspberry Pi boards, when the same amount of traffic -90 Mb/s of UDP traffic in our example-is sent/received. More in detail, this test aims to identify any power consumption increase due to the virtualization layer, both when the gateway acts as a server (receiving network traffic), and as a client (sending network traffic). From the results, we can observe that the power consumption of the Docker case slightly differs from the native execution. This implies that the power overhead generated by the Virtual Network Interface Card (virtual NIC) -when handling UDP traffic-is extremely low.

B. Gateway Performance

After demonstrating that running multiple Docker containers on top of a Single Board Computer does not impact the performance, in this second part of performance evaluation, we want to test our gateway in order to assess which board is more performing -by considering also the power consumption trade-off-while performing the same tasks. We assume that the Database, the Orchestrator, and the Web Server containers have been created -but not initialized-by a remote user.

The experiment conducted can be described as follows: in a first stage, the containers are booted up through the socket/proxy activation; a later phase characterized by the interaction sensors-gateway, in which a sensor sends data packets -13 bytes-every 60 seconds -according to ETSI specifications [11]-. As sensor platform, we used Maxfor nodes. These nodes embed a MSP430 as CPU and Texas Instruments CC242011 as radio frequency module; they are also equipped with temperature and light sensors. The nodes use Contiki-OS 12 as operating system and in particular we flashed their firmware with CACHACA (Confidentbased Adaptable Connected objects discovery to HArmonize smart City Applications) a ranking mechanism that we proposed in [START_REF] Petrolo | Confident-based Adaptable Connected objects discovery to HArmonize smart City Applications[END_REF]. By running this algorithm, sensor nodes can evaluate and classify neighbors and the services that they offer (e.g., temperature, light, humidity, etc). CACHACA is based on a rule-based fuzzy inference system and the use of physical parameters -such as the Received Signal Strength Indication (RSSI)-in order to rank neighborhood and services.

The overall duration of the test is one hour and two minutes, where the first two minutes are used to create and initialize the containers. In this span of time, different performance metrics have been stored; the Raspberry Pi power consumption, and the resources -CPU, Memory-employed by each running container, thanks to the docker stats command.

Figure 6 shows the outcome of this evaluation. In Figure 6a the CPU resource usage of each single container is shown. It can be observed that the total amount of employed CPU resources does not exceed 10%. The web server is the component that produces the higher CPU utilization (approximately 5%). Raspberry Pi3 is the board that shows optimized performance compared to Raspberry Pi2. From the Memory performance perspective (Fig. 6b), we can mainly notice a relevant resource usage optimization in the RPi3 for each component container, which is then reflected in the overall percentage. Again, the web server is the container more greedy in terms of resources. In both cases analyzed previously, the Orchestrator is the container that requires less resources. Another clear aspect coming from this evaluation is the better efficiency of RPi3 compared to RPi2. However, in the comparison RPi2/RPi3 the trade-off between power consumption and performance has to be considered. In Figure 6c, the average power consumption of the two devices under test is depicted. The better RPi3 performance are achieved at the expense of a slight higher power consumption -approximately 12% higher-.

V. CONCLUSION

In this paper, we introduced a lightweight Edge Gatewayas-a-Service and its architecture. Through the use of container vitrualization technologies we satisfied many platform requirements. Our proposal has been validated by means of a wide performance evaluation. The main insights coming from

Fig. 1 :

 1 Fig. 1: Gateway Architecture.

Fig. 2 :

 2 Fig. 2: The gateway can be shared between different tenants.

Fig. 3 :

 3 Fig. 3: Container activation through socket/proxy connection.

  (a) Gateway -Sensor. (b) User -Gateway.(c) User -Sensors.

Fig. 4 :

 4 Fig. 4: Gateway interactions with remote users and sensors.

Fig. 5 :

 5 Fig. 5: General Performance Evaluation.

  (a) CPU resource usage. (b) RAM resource usage.(c) Gateway power consumption.

Fig. 6 :

 6 Fig. 6: Gateway performance.

TABLE I :

 I Raspberry Pi 2 and Raspberry Pi 3 features. Operating System, we use the image provided by Hypriot 4 running Raspbian Jessie with Linux kernel 4.4.10. Both RPis use 16 GB (Transcend Premium 400x Class 10 UHS-I microSDHCTM) memory card as storage device.

	Chipset	Broadcom BCM2836	Broadcom BCM2837
	CPU	Quad-Core @900MHz	Quad-Core @1.2GHz
	Memory	1GB LP-DDR2 400MHz	1GB LP-DDR2 900MHz
	GPU	Broadcom VideoCore IV	Broadcom VideoCore IV
	Ethernet	10/100 Mb/s	10/100 Mb/s
	Flash Storage	MicroSD	MicroSD
	Connectivity USB	4USB 2.0 Host	4USB 2.0 Host
	OS	Linux, Windows 10	Linux, Windows 10
	Price	$35	$35
	As base

Raspberry Pi 2 model B Raspberry Pi 3 model B

This work is partially supported by CPER DATA, the FP7 VITAL project, the CAPES-COFECUB CROMO project, and by the FP7 Marie Curie METRICS project.

https://www.raspberrypi.org/

https://www.raspberrypi.org/products/raspberry-pi-2-model-b

https://www.raspberrypi.org/products/raspberry-pi-3-model-b

http://blog.hypriot.com

https://www.docker.io/

http://wildfly.org

https://www.elastic.co

http://manpages.ubuntu.com/manpages/wily/en/man1/sysbench.1.html

http://manpages.ubuntu.com/manpages/wily/en/man1/mbw.1.html

http://linux.die.net/man/1/fio

http://www.ti.com/product/CC2420

http://www.contiki-os.org the validation are two-fold: (i) we have demonstrated that employing virtualization technologies on top of constrained devices has an almost negligible impact in terms of performance; (ii) the low resource usage of our gateway confirms the lightweight characteristics of our design, revealing promising results in terms of scalability and energy efficiency. The GaaS described in this paper is targeted for being employed in different IoT contexts -such as, smart home, buildings, farms, etc.-thanks also to the use of semantic technologies that enable interoberability among heterogeneous devices.