modify script to prevent any quality loss after images offset procedure:
using System;
using System.IO;
using System.Drawing;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using System.Collections.Concurrent;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Globalization;

class ImageShifter
{
    static void ShiftImage(string imagePath, float xOffset, float yOffset)
    {
        try
        {
            Mat image = CvInvoke.Imread(imagePath, ImreadModes.Unchanged);
            if (image.IsEmpty)
            {
                Console.WriteLine($"Could not open or find the image: {imagePath}");
                return;
            }

            Mat shiftedImage = new Mat();
            var translationMatrix = new Emgu.CV.Matrix<double>(2, 3);
            translationMatrix[0, 0] = 1.0; // Scale x
            translationMatrix[0, 1] = 0.0; // No rotation
            translationMatrix[0, 2] = xOffset; // X translation
            translationMatrix[1, 0] = 0.0; // No rotation
            translationMatrix[1, 1] = 1.0; // Scale y
            translationMatrix[1, 2] = yOffset; // Y translation

            CvInvoke.WarpAffine(image, shiftedImage, translationMatrix, image.Size, Inter.Linear, Warp.Default, BorderType.Reflect, new MCvScalar());

            CvInvoke.Imwrite(imagePath, shiftedImage);
            Console.WriteLine($"Processed and overwritten {Path.GetFileName(imagePath)}");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error processing {Path.GetFileName(imagePath)}: {ex.Message}");
        }
    }

    static void ProcessImages(string inputDir, float xOffset, float yOffset)
    {
        string[] files = Directory.GetFiles(inputDir, "*.*", SearchOption.TopDirectoryOnly)
                    .Where(f => f.EndsWith(".png", StringComparison.OrdinalIgnoreCase) ||
                                f.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) ||
                                f.EndsWith(".jpeg", StringComparison.OrdinalIgnoreCase)).ToArray();

        ConcurrentBag<string> processedFiles = new ConcurrentBag<string>();
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.Start();

        Parallel.ForEach(files, new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, (file) =>
        {
            ShiftImage(file, xOffset, yOffset);
            processedFiles.Add(file);
        });

        stopwatch.Stop();
        Console.WriteLine($"Processed {processedFiles.Count} images in {stopwatch.Elapsed.TotalSeconds:F2} seconds.");
    }

    static void Main(string[] args)
    {
        if (args.Length < 3)
        {
            Console.WriteLine("Usage: <executable> <input_directory> <x_offset> <y_offset>");
            return;
        }

        string inputDir = args[0];
        if (!Directory.Exists(inputDir))
        {
            Console.WriteLine($"Input directory does not exist: {inputDir}");
            return;
        }

        if (!float.TryParse(args[1], NumberStyles.Float, CultureInfo.InvariantCulture, out float xOffset))
        {
            Console.WriteLine("Invalid x offset value.");
            return;
        }

        if (!float.TryParse(args[2], NumberStyles.Float, CultureInfo.InvariantCulture, out float yOffset))
        {
            Console.WriteLine("Invalid y offset value.");
            return;
        }

        ProcessImages(inputDir, xOffset, yOffset);
    }
}