Comparing Freeman Chain Code 4 Adjacency Algorithm and LZMA Algorithm in Binary Image Compression

Image is one product that has experienced a significant increase in quality. Insufficient internet capacity makes it difficult to access large images. Image compression is one way to solve this problem, but image compression can make image quality degrade. This research uses lossless compression algorithms, namely Chain Code Algorithm and LZMA Algorithm, to reduce the quality of the image and can be adjusted the tolerance value manually. In the application that will be created, the user can select the image to be compressed, then compress it according to the tolerance value that has been set and with the compression result of a text file, where the text file can be extracted and reconstructed into an image. There will be a preview of the results of the image compression and a description of the size and quality reduction levels. The conclusion of this research is that Chain Code Algorithm and LZMA Algorithm are able to compress image file sizes / images with extensions .jpg, .png. .bmp with a success rate of 90% from 50 tests.


Introduction
Informatics is one of the fields of science and technology that is developing rapidly so that it can play a role in helping humans obtain a more perfect life [1]. Since the discovery of a tool to capture an image in a twodimensional plane (image) in the form of a camera, with the development of technology at this time, it does not only focus on the tools used to capture the image. The problem with images is the amount of storage space required because the image files obtained are very large and can occupy a lot of space in the storage media. In addition, large image data when sent over the network will make sending images from one place to another slow down [2]. A large bitmap image size will affect the process of transmitting or sending the image over a computer network. For example, a 24-bit bitmap image with dimensions of 1024 x 768 pixels requires about 2 Mb of storage memory. So that the larger the size of an image, the transmission speed is also slower and requires a large storage memory. Through compression with the right algorithm can change the image size with a slight change in image quality without losing the information in it [3].
Image compression aims to reduce data sets that are similar to images so that they can be stored in a smaller size or transmitted efficiently and to find image representations with reduced pixel correlation. The two basic  [4]. In a communication system, the bandwidth required for digital image utilization is quite large. Because the channel capacity is limited, it is necessary to develop image data compression techniques [5]. Image quality improvement is needed to experience noise when sending via transmission line, image is too light or dark, image is not sharp, blurred, and so on [6]. Digital image processing is an image processing technique that aims to improve image quality so that it can be easily interpreted by humans or computer machines, which can be in the form of photos or moving images, digital image processing has several advantages, namely cheap, fast, and not damaging to what is measured and able to identify physically products objectively [7]. Reducing the file size allows more images to be stored in a certain amount of disk or memory space. The first type of compression is called lossless compression, while the latter is called lossy compression [8]. Compression requires algorithms and some prominent compression algorithm techniques such as Huffman, Run Length Encoding, Arithmetic, and Entropy. Image compression is data compression to reduce the digital size of the image. Compressed image formats are GIF, PNG, JPEG and others [9]. In the Lossless compression technique, data compression, when decompressed, becomes a replica of the actual data. When binary data is compressed, it is necessary to reproduce properly when decompressed. The actual image likeness is sufficient for the most objective, as far as errors or problems between the actual image and the compressed image can be avoided. It is used for only a few specific applications simultaneously with rigid requirements such as medical imaging [10]. Lossy compression is used to reduce the size of the bitmap image. First, the original image goes through four stages, namely, decomposition, quantization, modeling and coding, and finally the compressed image. Through this process, the image loses some size from its original form while maintaining its original quality, but in a compressed form [11].
Chain codes are a popular representation method for form rasterization in various scientific and engineering disciplines, the most intuitive chain code proposed by Freeman in 1961 using 8 pixel connectivity [12]. Chaincodes are used to represent the shape boundaries of each object in the image by registering a list of edge points along the contour and specifying the direction of the contours on each edge in a list of numbers. The direction of each edge is quantified to be one of 4 or 8 directions. The resulting chain code is based on determining the starting point at the first edge in the contour list and moving clockwise around the contour, traversing from one pixel to the next boundary pixel [13].

Figure 1. Encoder and Decoder LZMA
LZMA is a type of lossless compression algorithm that uses a large size to generate a compression scheme. The basic idea is to use multiple data structures to generate different symbols in the original file and then use a range encoder to encode these repeating symbols. It is a variant of the LZ family which differs in terms of construction and size used for compression [14]. The LZMA algorithm uses delta encoder and sliding dictionary encoder together with the LZ77 dynamic coding concept. The output of the LZMA encoder is represented in the form of a tuple (offset, length, new symbol). Delta filters form the input data stream for effective compression by sliding windows. It stores or transmits data in the form of differences between sequential data. The output of the first byte of the encoding is the data stream itself. The next bytes are stored as the difference between the current and the current bytes before. While the output of the delta decoder is to maintain the first data stream and the next byte is stored in addition between the current data and the previous byte. For real-time data that is constantly changing, delta encoding makes dictionary slide more efficient [15].

Research Methodology
The research begins by identifying problems that arise in system design. Literature is obtained by collecting various written sources such as journals, books, archives and relevant documents. The system development uses the Waterfall mechanism, so that each process is carried out regularly and does not overlap. The Needs Analysis Stage aims to identify the needs in designing or building an application system. The system design stage designs the interface of the system so that it is easy to use by the user. The coding stage uses the C# programming language. The final stage is Testing, this stage uses the Chain Code 4 algorithm and the LZMA algorithm. System design is needed to describe and determine the process flow that will be carried out in the system in the form of diagrams that describe how the system works and interacts with users starting from flowcharts, use cases, activity diagrams, and gantt charts. In Figure 2, illustrates the process of the Freeman Chain Code 4 Adjacency algorithm when forming a chain code as follows, the binary array of the original image that you want to compress, the terms or conditions i <image width, j <image height, if pixel (i,j) = 0 , then move sideways, if pixel (i+1,j) = 0, then form code 1. If not then move on to the next process, if pixel (i,j+1) = 0, then form code 2. If not then continue to the next process, if pixel (i-j,j) = 0, then form code 3. If not then continue to the next process, if pixel (i,j-1) = 0, then form code 4. If not then process over.

Discussion and Analysis
Implementation begins by using the Freeman Chain Code 4 Adjacency, this method is by calculating the distance of movement along a digital curve or successive pixel boundaries based on 4 connectivity directions, the direction of each movement is coded using the number scheme [i | i = 0,1,2,3] which is the multiple of the 90 degree counterclockwise angle of the positive x-axis. The next stage uses the LZMA method to compress data files with a high compression level, the result is a file that is much smaller in size than before it was compressed. The use of this method is by calculating the encoding and decoding processes. The results of these calculations produce the values used for the image compression process. When the user runs the program, there will be an initial display of the program that will be run by the user. In the program display, the 'Select Image' button will be used to enter a sketch image that will be processed by the user. After the user inserts the image, the user will convert the image into binary form. After being binned, the images that have been entered by the user will be chain coded and mapped into csv format, after which they will be compressed using LZMA. Then, the compressed file will be extracted by the user by pressing the "Extract" button and to save by pressing the "Save" button. In the binarization process, it contains the process for converting an RGB image into a binary image, after which it is displayed in the picture box and the size of the binary image on the label. In the compression process, it contains the process to chain code the binary image, enter the coordinates and chain code in a new file with the .csv format, then perform LZMA compression on the csv file, display the compressed image results and the size of each file and path location. In the extraction process, contains the process for extracting the LZMA compressed file to the chain code file. After getting the chain code file, perform chain extraction to remap the binary image. Figure 3 shows a display of the extraction results.