Keywords

1 Introduction

A binary or a bi-level image is a computerized image which holds two values for each pixel. These values are normally black and white. Binary images can be used in a variety of applications such as analyzing textual documents and representing gnomic strings [24, 35]. One advantage of binary images is their small size compared to grayscale and color images. A concern that remains to impact the image processing domain is the growing of extremely large amounts of data everyday. This issue makes it crucial to explore new image compression techniques. A tremendous amount of work has been done in the field of image compression and researchers tackled the problem from different perspectives. JBIG1 is an international standard designed to compress binary images such as fax documents [13]. JBIG2 is a newer standard in binary image compression. In JBIG2, an image is typically decomposed into distinct parts and each part is encoded via a separate method [23]. In addition to JBIG1 and JBIG2 standards, researchers employed different techniques for binary image coding and compression such as the Freeman [6, 7], arithmetic [26] and Huffman coding [11].

The extensive literature review reveals that agent-based modeling is a new direction in image compression and coding. Recent work by Mouring et al. [20] indicates that agent-based modeling is an effective and a promising approach to capture the characteristics of a binary image which allows coding and compression. In fact, utilizing the rules of biological ants (i.e. pheromone), the ant colonies algorithm offered by Mouring et al. [20] could outperform well-known algorithms such as JBIG1 and JBIG2. The present research aims at challenging the ant colonies model via utilizing the movements of wolves in a wolf-sheep predation model. Interestingly, it has less details and easier to implement while generating better compression results than the ant-colonies model [20]. In the wolf-sheep predation model, wolves wander around to find sheep to prey on in order to avoid dying. To this end, a binary image is converted to a contour image which is then converted to a virtual world of sheep and routes where a wolf can have certain moves according to specified rules. The purpose of the wolf movements is to identify sheep and thus, such movements can serve as a new image representation. These movements are also designed to take advantage of the arithmetic coding which is used to compress the final string of the wolf movements. Additionally, since it is an agent-based model, the researcher can control the number of agents that work simultaneously in the virtual world, which in turn, generates different results depending on the specifications of each particular image. Agent-based modeling also offers the capability to add certain behavior depending on the type of the agent. The researcher can explore with different settings and identify the best parameters to choose. These features make this algorithm different than many other image processing techniques. The main contributions of this article are the following:

  • The present model takes advantage of the wolf-sheep predation model to produce a higher compression ratio than many other existing methods in the field of binary image compression including JBIG1 and JBIG2 standards. The extensive literature review did not reveal any previous work which utilized the wolf-sheep predation model in binary image compression.

  • Agent-based modeling is a new direction in image compression and coding. The utilization of agent-based modeling allows the exploration of different behaviors which makes the agent-based modeling approach different than many other classical coding approaches in the literature [16, 17, 37].

  • The current study introduces a new wolf movement, which is captured via a total of eight possible directions. This is less than the number of chains in the researcher’s previous work in chain coding [37] where there were 10 possible chains.

  • The algorithm is simple to implement compared to JBIG1 [13], JBIG2 [22, 23] and the ant colonies model [20]. Interestingly, it could outperform all of them in all the testing images.

The paper is organized as follows: related work in agent-based modeling and binary image coding and compression is presented in Sect. 2. The proposed model is described in Sect. 3. The results and discussion regarding the application of this algorithm on a dataset and the comparison with other algorithms in the research community are discussed in Sect. 4. Finally, Sect. 5 provides conclusions.

2 Related Work

This section explores existing work in agent-based modeling domain related to the movements and shows how this influences this research in image compression. Furthermore, it explores related work in image coding and compression and demonstrates an agent movement as a new approach utilized in image coding and representation.

2.1 Agent-Based Modeling

Agent-based modeling has been an attractive domain to researchers from different backgrounds and it is aimed at solving many real-life problems. It is a way to simulate systems consisting of interacting agents. Research reveals that agent-based modeling plays a crucial role in solving many computer science problems. A highly remarkable achievement in the field of agent-based modeling is the development of Netlogo [31], which is a programming environment designed to help different audiences including domain experts with no prior programming background. Netlogo has a library which is preloaded with a considerable amount of models utilized by researchers from different fields such as biology, computing, earth science, games, psychology, arts, physics and mathematics. These models can help investigators understand many life problems with complex phenomena.

One of the most well-known Netlogo models is the wolf-sheep predation model [30, 33], which investigates the balance of ecosystems consisting of predators and preys. One alteration of the model is to include wolves and sheep where wolves are looking for sheep to restore their energy and thus, avoid dying. Additionally, this variation allows sheep and wolves to reproduce at a certain rate, which enables them to persist. In another more complex alteration, it models sheep, wolves and grass where sheep must eat grass to preserve their energy. This model has been subjected to further research and development and it has been examined from various views such as offering instruction in life sciences [8] and agent-based modeling research [5]. Whilst many research studies have been carried out on the wolf sheep predation model, none of them utilized it in image processing domain. The wolf-sheep predation model inspired the present study and it was mainly used in image coding and compression.

Similarly, Wilensky [32] has introduced the ethnocentrism model which proposes that there are many circumstances which contribute to developing an ethnocentric behavior. In this model, agents use different cooperation strategies such as collaborating with everyone and collaborating within the same group. Numerous scholars have investigated the ethnocentrism model and its applications. Bausch [2] has demonstrated more collaboration when certain groups are eliminated. In 2015, the paths model was developed and it is concerned with how pathways come out along usually traveled ways where people are more inclined to follow popular routes taken by other people before them [9]. These paths can be influential in developing agent-based models which contain paths agents can walk through depending on many circumstances. Furthermore, analyzing the behavior of human agents has been examined in literature. Kvassay et al. [14] have developed a new approach which depends on casual partitioning to examine the human behavior via an agent-based model. In another study, Carbo et al. [3] have introduced an agent-based simulation to assess an ambient intelligence scheme which measures satisfaction and time savings depending on agents. They use Netlogo to simulate an airport with travelers passing through different stops such as shopping and boarding gates.

Ant colonies have been a subject of research in agent-based modeling. The ants model simulates a virtual environment of ants searching for food according to a set of rules [29]. When an ant discovers a food item, it carries it back to the nest while releasing a pheromone which can be sniffed by the surrounding ants. Pheromone attracts ants to that food source. The extensive literature review reveals one study utilizing agent-based modeling in binary image compression by Mouring et al. [20]. They have built a model for image compression which simulates an ant colony. In their study, an image is converted to a virtual environment with ants moving over the routes and searching for food items. The search process in the algorithm is influenced by the pheromones released and the other ants in the neighborhood. The results of the ant colonies algorithm were promising and they could significantly produce better compression ratios than JBIG1 and JBIG2. The difference between this research and the ant colonies algorithm by Mouring et al. [20] is that this algorithm has a new set of rules which were not utilized in the ant colonies research. In turn, the compression ratios of the wolf-sheep predation model are higher than those obtained by the ant colonies model offered by Mouring et al. [20] in all the testing images.

2.2 Binary Image Compression

With the introduction of Internet and social media, there is a continual increase in the amounts of data generated everyday. This makes it imperative to explore new mechanisms to process and compress the data in order to transmit it efficiently over the media channels. The topic of compression has attracted much attention in the research community and it has been extensively studied from different perspectives. One of the most remarkable achievements that has drawn the attention of many image compression researchers is arithmetic encoding [26, 34]. This technique is widely used by investigators from different domains and was subject to further improvement and development over the years. Anandan and Sabeenian [1] have described a method to compress medical images using Fast Discrete Curvelet Transform and coded the coefficients using arithmetic coding. In a different study, Masmoudi and Masmoudi [18] have investigated a new mechanism for lossless compression which utilizes arithmetic coding and codes an image block by block. Recently, Shahriyar et al. [27] have proposed a lossless depth coding mechanism based on a binary tree which produces a compression ratio between 20 to 80. Furthermore, Zhou [39] has proposed an algorithm which exploits the redundancy in 2D images and improved the arithmetic coding to provide a better compression of the data.

Literature shows that researchers incorporate arithmetic encoding with other image processing techniques. A widely used approach in the field of data compression is the chain coding which has been developed further after Freeman Code [7]. It keeps track of the image contour information and records each traversed direction. The subject of chain coding has been extensively explored and analyzed over the years. Minami and Shinohara [19] have introduced a new concept called the multiple grid chain code which utilizes square grids in encoding lines. Furthermore, Zhao et al. [38] have introduced a new approach to identify the related parts in a bi-level image. Another advancement is the representation of voxel-based objects via chain code strings by Martínez et al. [17]. In a different vein, Liu and Žalik [16] have presented a new chain code where the elements were encoded based on the relative angle difference between the current and the previous direction. Then, they have compressed the resulting string using Huffman coding. Likewise, Zahir and Dhou [37] have introduced a chain coding technique for lossy and lossless compression which takes advantage of the sequence of the consecutive directions and encodes them using a particular set of rules. In a different vein, Yeh et al. [36] have presented the Ideal-segmented Chain Coding (IsCC) method which employs 4-connected chains that can move in certain directions.

Along with improvements, the subject of chain code has been utilized in many applications. For example, Decker et al. [4] have introduced a new tracking mechanism to be used in endoscopy which overcomes the obstacles in soft surgery. Additionally, Ngan et al. [21] have employed the 3D chain codes in representing the paths of human movement. Coding was also used by researchers for different purposes in image processing. For example, Priyadarshini and Sahoo [25] have proposed a new method for lossless image compression of Freeman coding. Their method has achieved an average space saving of 18% and 50% for Freeman 8-directional and 4-directional chain codes, respectively. In another study, Liaghati et al. [15] have proposed a compression method for ROI maps which relies onto partitioning the image into blocks of the same size, applying a conversion on each block and then running code for compression.

Although all the previous methods handle the problem of image coding and compression from different perspectives, the extensive literature review has revealed that there is only one study utilizing the agent-based model of ant colonies in binary image coding and compression [20]. In this research a different model is utilized for image coding and compression which takes advantage of the wolf-sheep predation model and as shown, the results could outperform many existing methods in the research community including the recent ants model and JBIG family [10, 12, 13, 20, 23, 28, 39]. Despite the fact that image coding and compression has research grounds in image processing [6, 7, 16, 25, 37, 38], an agent-based modeling approach has a number of attractive advantages over the classical approaches of chain coding the considerable literature review revealed:

  • The researcher can add an agent behavior to be included in the model. For example, in the agent-based model utilizing ant colonies for image coding and compression, Mouring et al. [20] have utilized the concept of pheromone to attract ants to move to certain locations of the image. Similarly, the researcher can add more behavior to the wolf-sheep predation model such as the concepts of the grass and reproduction. This does not exist in chain coding.

  • Agents can work on different parts of the image at the same time. For instance, the ant colonies algorithm has the proximity awareness feature, which allows the virtual ants to move to certain parts of the image with less density of ants. The number of agents working on the image is a parameter which can be controlled by the programmer. Likewise, in the wolf-sheep predation model, the researcher can control the number and the directions of wolves depending on the virtual world.

  • Agent-based modeling approaches can have less number of movements as opposed to the chain coding directions in some chain coding approaches. For example, the lossless chain coding technique offered by Zahir and Dhou [37] provides a total of ten directions while the ant colonies algorithm has four or five movement possibilities depending on whether the movement is related or normal. Likewise, in the current wolf-sheep predation model, the movement of the wolf can only have one of eight possibilities.

3 The Proposed Agent-Based Modeling Algorithm

In this paper, the researcher proposes an algorithm for bi-level image coding based on the wolf-sheep predation model [30] which can also be used in binary image compression. The idea of the model is based on the movements of wolves to find sheep in a predatory-prey system. The researcher believes that this work paves the way for a new direction on image analysis using agent-based modeling. In the present model, a moving agent is represented by a wolf and the movement is for the purpose of searching for sheep. At the beginning, a binary image is converted to a contour representation which is then transformed to a virtual world consisting of a wolf, sheep and routes where the wolf can walk to search for the sheep. Each zero pixel in the binary image is replaced by a route and each 1 pixel is replaced by a sheep as shown in the example in Fig. 1.

Fig. 1.
figure 1

An example of a binary image converted to a virtual world of sheep, routes and a wolf searching for sheep

The wolf starts from the upper-left position and starts searching for sheep and once he finds a sheep, he moves to that location and so on. Each time a wolf moves to a new location, the movement is recorded based on the previous one. There are seven pertinent moves in the system which capture all the directions of the wolf in the virtual environment. These movements depend on the location of the wolf, the direction of attack and the location of the sheep as in Fig. 2. For example, if the wolf moves in the same direction as its previous move, the movement is recorded as Straight Move (SM). If the wolf moves sharp in the right direction, the movement is recorded as Right Move (RM). There is one exception to the straight movement of the wolf: If the wolf has the ability to move 8 consecutive steps in the same direction (i.e. Straight Move). In such a case, the movement is recorded as Big Straight Move (BSM).

Fig. 2.
figure 2

(a) Straight Move (b) Left Move; (c) Cross Left Move; (d) Cross Right Move; (e) Right Move; (f) Reverse Left Move; (g) Reverse Right Move

Other than the movement exception listed, the movement is encoded according to Fig. 2(a) through (g). The reason why the researcher designed the movement to include an exception is because he experimented with a large number of images and found that the percentage of occurrence of the Straight Move (SM) was about 50% of the time. Thus, by having the movement exception, the algorithm can achieve a high reduction on the agent movement, which in turn, provides a better compression ratio. In other words, using BSM movements offers further reduction to the series of movements and allows the arithmetic coding to provide a higher compression ratio when applied on the string representing the wolf movements. Some other movements of the wolf occur very rarely in images and thus, it would be of no value to have exceptions concerning them. After obtaining the chain of wolf movements, the researcher compressed them using arithmetic encoding, the purpose of which was to reduce the number of bits in the string. Figure 3 provides an example of coding an image using the current algorithm.

Fig. 3.
figure 3

An example of a wolf movement for the purpose of coding. The wolf starts searching from the upper-left portion of an image and then moves to the first location where he finds a sheep. Then, the wolf finds a sheep in a neighborhood location, thus moves to that location and so on. The relative movement of the wolf can be represented as: LM, SM, SM, SM, RM, SM, CRM, CLM, RM, CRM and SM

4 Results and Discussion

The proposed wolf sheep predation model was tested on a set of 8 binary images from [39]. The same set of images was used in the study of ant colonies by Mouring et al. [20]. For more information about the images, please refer to [39]. The experimental results showed that the number of bits resulting from compressing the wolf movements in the present model via arithmetic coding could outperform the results of many existing algorithms. Table 1 shows the results of the current wolf-sheep predation model as compared to other algorithms in the research community.

Table 1. Number of bits generated after compressing the chain of wolf movements using arithmetic coding in a wolf-sheep predation model as opposed to the number of bits generated by other existing algorithms [10, 12, 13, 20, 23, 28, 39]

Using the data in Table 1, the space savings metric was calculated using the equation below:

$$\begin{aligned} Space\,savings = 1-\frac{Compressed\,Size}{Uncompressed\,Size} \end{aligned}$$
(1)

The space savings metric was calculated for the wolf-sheep predation model as compared to other existing techniques. The space savings metric was 78.500%, 86.908%, 89.831%, 90.181% and 93.692% for G3, G4, JBIG1, JBIG2 and Ant Colonies Model, respectively while it was 94.511% for the current wolf sheep predation model. In addition, the current model uses one of eight codes to represent each movement (SM, LM, RM, CLM, CRM, RLM, RRM and BSM) as opposed to the previous work by Zahir and Dhou [37] which involved one of 10 codes to represent each direction.

5 Conclusion

The aim of the present study is to investigate the role of a modified wolf-sheep predation model in image coding and compression. In particular, a set of movements of wolves is designed the purpose of which is to encode and compress binary images. Specifically, eight wolf movements are introduced including a big movement which help further reduction of the string employed in image representation. The experimental results show that in terms of bit reduction offered by the compressed string of movements, the present agent-based model is superior to many other methods in binary compression including JBIG2 [22, 23] and the ant colonies algorithm [20]. Furthermore, the present method is easier to program than JBIG methods and the ant colonies algorithm.

The evidence from the findings of this study is that agent-based modeling can be utilized as a new approach in the field of image coding and analysis. The empirical findings of this study provide a new understanding to an agent-based modeling and its application in binary image coding compression. Furthermore, this research serves as a base for future studies that investigate the movements of agents in image analysis and representation.

A limitation of this study is that it does not address utilizing agent-based modeling in compressing grayscale and color images. Additionally, it is only limited to image coding and compression. Future work includes testing the algorithm on a larger set of images and applying the chains of agent movement in further image analysis. Furthermore, this project can be a starting point to more research in image analysis and compression of grayscale and color images using agent-based modeling approaches.