## 1 Introduction
Fundamentally, images can be characterized as a two-dimensional (2-D) function such as f(x, y), where x and y denote spatial (plane) coordinates, and the amplitude of f at any given coordinate pair (x, y) is referred to as intensity, brightness, or gray level [18; 19]. To enable processing, an image must first undergo digitization. In the case of digital images, the function is represented as f(i, j), where i and j are discrete integer values, as illustrated in Figure 1.  
Images are classified into two categories: grayscale images and colored images. A grayscale digital image is represented as an M x N pixel matrix, where the image captures only the intensity of light. Pixels in a digital image are typically represented as unsigned 8-bit integer values, ranging from 0 to 255. This range allows for the depiction of 256 discrete shades of gray, where 0 corresponds to black, 255 represents white, and the intermediate values indicate varying levels of gray intensity. Color images are represented and modeled as linear combinations of the three primary colors: red, green, and blue, forming the foundation of what is known as a color space. Widely used color spaces in digital imaging include HSV (Hue, Saturation, Value), RGB (Red, Green, Blue), and CMYK (Cyan, Magenta, Yellow, Black). In such images, each pixel is characterized by three matrices that represent its coordinates within a given color space in RGB. As each matrix consists of 8-bit values, this results in a precision of 24 bits per pixel, widely referred to as 24-bit color schema. From the perspective of image representation, traditional image compression algorithms are based on pixel-level operations [20; 21; 22], entropy coding [23; 24], block-based prediction [25; 26], integer transformations [27; 28], or combinations of these techniques [9; 29; 30]. The literature includes both lossy and lossless compression algorithms developed using these fundamental structures. Additionally, compression algorithms tailored to the specific characteristics of images have also been proposed [31; 32]. This study aims to contribute to the literature by introducing an advanced lossless compression algorithm applicable to all types of images. Since the algorithm is developed at the pixel level, it is designed to be universally applicable. A preprocessing step is incorporated to improve performance and achieve higher compression ratios, even while maintaining a lossless approach. During this preprocessing phase, the image is divided into small segments containing similar color tones. To guarantee data integrity throughout the process, a specialized data structure is developed to preserve and encapsulate all information. After preprocessing, the resulting data structure is compressed using a newly developed DEA and S+DEA, designed to maximize compression efficiency. Encoding and compression algorithms fulfill distinct yet interconnected roles in data processing. Encoding algorithms primarily structure data according to predefined rules, ensuring efficient representation without necessarily reducing its size. In contrast, compression algorithms are specifically designed to minimize data size by eliminating redundancy while retaining essential information. This process typically involves one or more preprocessing steps, which further enhance the overall efficiency of compression. As part of this study, a robust and efficient encoding algorithm, DEA, is initially developed. To enhance the performance and efficiency of the DEA, a preprocessing step in the form of segmentation is integrated into the algorithm, leading to the proposal of a novel compression algorithm, termed S+DEA. To assess and compare the effectiveness of the study, the DEA is evaluated against other encoding algorithms, while the S+DEA is compared with well-established lossless compression algorithms.