## 4 The Proposed Selective Retransmission Mechanism
### DWT-Based QoS  
There are many coding techniques suitable for wireless image sensor networks, each one bringing advantages and drawbacks [10]. Among the possibilities, DWT has been considered by the academic community as a flexible option for image coding [30], allowing a series of cross-layer optimizations for energy preservation with low impact on the application general quality. In fact, when applied over images, DWT can produce data with different priorities, and such priorities can be reflected into QoS levels that can be exploited for network optimizations. If packets carrying less relevant information are lost, the image quality is lower-bounded, and an acceptable played-out image quality is assured at the receiver size if more relevant packets successfully reach the sink. Wavelet transforms provide data decomposition in multiple levels of resolution, where DWT is achieved discretely sampling the wavelets. DWT decomposes a signal (a series of digital samples) by passing it through two filters: a lowpass filter L and a highpass filter H [30]. The lowpass subband represents a down-sampled low resolution version of the original signal, while the highpass subband contains residual information of the signal. For the perfect reconstruction of the original signal at the receiver side, all information from lowpass and highpass filters are necessary. Digital images are two-dimensional signals, usually represented as a matrix of pixels. A 2D DWT processes such signal considering the rows and columns, generating four subbands: LL, LH, HL and HH. The LL subband represents the lowest resolution and a half-sized version of the original image. In fact, it is the most significant information for the decoding process (without it, the image cannot be rebuilt), while the remaining subbands contain vertical, horizontal and diagonal details for the decoding process. Such processing produces two groups of relevance, but the LL subband can be transformed again to generate more levels of resolution. Figure 3 presents an original image that is processed by a DWT applied once and twice, resulting in two and three levels of resolution, respectively from left to right. In Figure 3, a grayscale 256 \(\times\) 256 pixels image is transformed by DWT, but the LL\({}_{(2)}\) subband (\(64\times 64\)) could be processed again to generate more levels of resolution. Apart from being influenced by the number of times DWT is applied, the resulted subbands are influenced by the coefficients of the lowpass and highpass filters [29, 30, 31], resulting in different discrete wavelet transforms. The original image is obtained by performing an inverse DWT over the computed subbands. The lowest resolution representation of the image (the LL\({}_{\text{(n)}}\) subband) is required, while the other subbands will be used to increase the quality of the final image. If the other subbands are lost, the image quality decreases. In fact, the acceptable image quality depends on the application requirements and the expected uses of the retrieved images, but many applications support reduction in the image quality due to changes in the network conditions. We must consider the fact that each bit must be transmitted over the sensor network, which implies energy consumption in the source and over the path(s) toward the sink. Moreover, retransmissions increase such energy consumption. In short, higher quality of received images usually demands more energy resources of the sensor network. Each packet will be assigned a QoS level according to the packet's payload. As the original images will be processed by 2D DWT, the QoS of each packet depends on the relevance of the produced subbands. The packet's QoS is represented by the Data Relevance (DR), an 8-bit field to be inserted in every transmitted packet, just after the fragmentation header \(f\). The value of DR is computed depending on the number of times DWT is applied, which in our proposed solution can be once (1-level) or twice (2-level).