# 4 KSecure: A Universal Method for Active Manipulation Detection in Images of Any Resolution
## 3 Method
### Method Overview  
By design, the 4 KSecure algorithm is not a traditional neural network architecture but a data processing concept integrated within existing models. Its primary goal is to enable the active embedding of integrity markers across the entire image surface, virtually independent of resolution, while minimizing computational resource requirements. While a similar approach could be applied to many convolutional networks [32], it often proves impractical in commercial settings due to the high hardware costs and increased processing time associated with handling huge input matrices. The main challenge is the high demand for GPU memory (VRAM) and the extended computation time, significantly impacting efficiency when processing high-resolution images. In the proposed solution, we mitigate these challenges by introducing an \"intermediate\" resolution and implementing efficient memory switching between the GPU and CPU. Large matrices (e.g., in 4K resolution and beyond) are temporarily stored in the computer's RAM, which is more affordable and more straightforward to expand. Meanwhile, operations on smaller matrices, including neural network inference, are primarily performed on the GPU. This approach significantly reduces the GPU workload and minimizes VRAM requirements, making it possible to process high-resolution images more efficiently without excessive hardware constraints. Figure 1 presents a data flow diagram divided into two parts: Figure 1a and Figure 1b. Depending on the design and available hardware resources, the input image and intermediate data can be stored in different types of memory, such as conventional system RAM or computational accelerator memory, typically GPU memory. In the diagram, different colors distinguish data allocated to GPU memory from data stored in RAM, clearly visualizing how memory management is structured within the system. Figure 1a illustrates the encoding process, which involves embedding additional data into the carrier image to enable the later detection of potential manipulations. In the 4 KSecure algorithm, the entire data flow is structured to prevent large matrices from being processed in GPU memory at any point. At the beginning of the process, the high-resolution image is downsampled, reducing its dimensions to what is referred to as an intermediate resolution, a predefined format in which the neural networks used in the system operate. The resulting smaller image is then transferred to the GPU. Depending on the specific use case, additional data, such as metadata, binary masks, other images [32], encoding keys or object identifiers, can be embedded. The network then produces an artifact (in this scenario, a three-channel mask), representing a processed input image transformation. In 4 KSecure, this artifact serves as an integrity marker, enabling future modification detection in the image. The generated artifact is subsequently sent back to the CPU, and it undergoes  
Figure 1: Data flow scheme and data allocation in the 4 KSecure algorithm. (**a**) Encoder side, (**b**) decoder side. upsampling to match the original image's resolution. This ensures that large matrices are never stored in GPU memory, significantly reducing hardware requirements. Once this process is completed, the mask is added to the input image, which is stored in the system RAM. The final result is a new image, now enhanced with an invisible signature, ready for publication or distribution through any chosen channel. Figure 1b illustrates the decoding process. In this stage, the system loads an image, which is then downsampled to a predefined and fixed intermediate resolution. The resized image is then fed into the decoder network. In this scenario, the key objective is to detect and localize manipulated regions and perform a binary classification to determine whether the image has been modified. The decoder network analyzes the artifact embedded in the image and determines whether its integrity has been compromised.