## 5 Image Compression  
Our sensor nodes are embedded devices running on battery power. Thus, we needed to develop algorithms that take into account the limited computational and memory resources available on these devices, their limited radio bandwidth and the power constraints under which these devices operate. Image compression will allow us to reduce the number of packets per image to be transmitted over the radio, which will reduce the overall power consumption and allow us to transmit more images for higher resolution data [10]. However, the image compression algorithm must be simple enough to be implemented on these resource-constrained, embedded devices. Specifically, our nodes have 64 kB of SRAM memory, out of which around 5 kB were used for infrastructure code, leaving us with only around 59 kB for image storage and processing. Each 128 \(\times\) 128 grey-scale image consumes 16 kB of memory, which allows us to have at most three images in the memory for simple processing, like 'C = process(A, B)'. Each 200 \(\times\) 200 grey-scale image consumes 40 kB, giving us no extra room for another image, other than the one that is being taken from the camera sensor. For these reasons, we have employed two different compression algorithms for our pitfall trap deployment and the bird nest deployment. In the pitfall trap deployment, the requirement was that we need to 'detect' an event when an animal is captured in the trap. If there are no events, biologist need not visit those traps for investigation and rescue. Thus, images are not required to be transmitted when there are no events, but must be transmitted when there are. Once the animal has been rescued, the trap can go back to the no event state. For this reason, we used a simple \"background subtraction-based object detection\" [11] algorithm on 128 \(\times\) 128 grey-scale images for the pitfall trap deployment. This seemed to be an ideal choice, not only because ofits low memory and computation requirements, but also due to the fact that the cameras are pointed at an enclosed, unmoving background. In this algorithm, if the newly-taken image differs from the previous one, we say 'detected'. By 'differ' we mean, for the pixel with the largest gray scale value difference greater than a threshold value 'THRESH', 'M' pixels out of 'N' pixels around that pixel have a gray scale value difference greater than 'THRESH'. If 'detected', we transmit the image, otherwise not. A threshold value was used to take into account minor differences in the light intensity. Figure 1 depicts an example of this procedure. A newly taken image 'A' is compared with the previous image 'B', and the background subtracted 'A-B' is used for object detection. The black and white dots in the 'A-B' image are due to minor (\(\pm\)1) differences in light intensity, which translated into 0/255 gray scale values. Offsetting the 'A-B' image with a fixed constant 'X = 100' ('A-B + X') proves this, where 'X' can be any positive constant large enough to mask the minor (\(\pm\)1\(\sim\)2) differences and noise in light intensity (e.g., \(\mathrm{X}>\) 4). (In other words, using any value greater than four will result in identical detection algorithm behavior. One hundred was randomly chosen among the values that show the ('A-B + X') difffigure nicely for presentation.) SCOPES [12] also used a similar technique with the background updated using EWMA. However, we found that updating the background using EWMA created an artificial background that does not represent any real background at any instance in time and that created more false positives in our scenario. As we will describe in more detail later in Section 6, our background subtraction-based object detection algorithm not only detected true events, but also had several false positives, motivating improvements. Many of the transferred images were triggered as a result of changes in the intensity of sunlight or when the image was completely dark at night. In the bird nest deployment, the requirements were different from the pitfall trap deployment.