# Methodology ## Functional Requirements and Tasks ### Image Loading and Creation - - **Image.Load**: Loads an image from a byte array with the RGBA32 pixel format. - **Image.LoadPixelData**: Loads pixel data into an image with L8 (grayscale) format. - **Image.LoadAsync**: Loads an image asynchronously. - **new Image**: Creates a new image with Byte4 pixel format. ### Image Processing and Manipulation - - **Clone**: Clones the image for manipulation. - **Mutate**: Applies various image processing operations. - **Resize**: Resizes the image. - **Grayscale**: Converts the image to grayscale. - **ColorSpaceConverter**: Provides methods to allow the conversion of color values between different color spaces. ### Pixel Formats - - **Rgba32**: Represents a pixel format with red, green, blue, and alpha channels. - **Rgb24**: Represents a pixel format with red, green, and blue channels. - **L8**: Represents a grayscale pixel format. - **Byte4**: Represents a pixel format with four byte values. - **YCbCr**: Represents a YCbCr (luminance, blue chroma, red chroma) color as defined in the ITU-T T.871 specification for the JFIF use with Jpeg. ### Pixel Access and Manipulation - - Access individual pixels and convert them to Rgba32. - **ProcessPixelRows**: Processes image pixel rows for manipulation. - **ToRgba32**: Converts pixel to RGBA32 format. ### Image Metadata and Conversion - - **ImageFrame.SavePixelData**: Saves pixel data of the specified format. - **PixelOperations.PackFromRgbPlanes**: Packs pixel data from RGB planes. - **ImageFrame.GetPixelSpan**: Retrieves pixel span of the specified format. ### Creating and Disposing Image Instances - - **Creating an Empty Canvas**: - Create an empty canvas using Image\ with specified width, height, and RGBA color values. - **Disposing of the Canvas**: - Call the dispose method on the canvas object to free resources when it is no longer needed. - **new Rectangle**: - Creates a new structure that represents a rectangular region defined by its location (x, y, width, height). ### Cropping and Resizing - - **Mutate Method**: - Perform image transformations such as cropping and resizing. - Specify cropping rectangle and resizing options, including mode, size, and resampler. ### Encoding Images in Various Formats - - **ConvertImage Method**: - Handle image encoding into different formats. - Use encoders like GifEncoder, JpegEncoder, PbmEncoder, PngEncoder, TgaEncoder, TiffEncoder, and WebpEncoder based on the specified output format. ### Composing Image Layers - - **Stitch Method**: - Combine image tiles into the canvas. - Assemble the final image from smaller pieces. ### Resampling Methods - - **GetResampler Method**: - Return a resampler based on the specified resampler type. - Common resampling techniques include Bicubic and Box, among others. - **public interface IResampler**: - Encapsulates an interpolation algorithm for resampling images. ### Saving the image - - **SaveAsBmpAsync:** Saves the image to the given stream with the Bmp format. ## Performance Metrics This section outlines the performance metrics used to evaluate the image processing libraries. The metrics focus on two primary tests: Image Conversion and Pixel Iteration. Each test measures the time taken and memory usage for specific image processing tasks, providing a comprehensive assessment of each library’s performance. ### Performance Metrics #### Image Conversion Test Measure the time taken to load an image and convert its format using each library, as well as the memory usage during the process. **Steps:** 1. Load the image into memory. 2. Convert the image to another format (e.g., JPG to PNG). 3. Save the converted image to disk. **Metrics:** - Time taken to load the image and to convert the image format. - Memory usage will be measured. #### Pixel Iteration Test Measure the time taken and memory usage to iterate through all the pixels of an image, which is often necessary for tasks like filtering, color adjustments, or complex image processing operations. **Steps:** 1. Load the image into memory. 2. Iterate through every pixel in the image, applying a simple operation (converting to grayscale). **Metrics:** - Time taken to complete the pixel iteration process. - Memory usage during the pixel iteration process. ## Benchmarking Setup and Tools This evaluation uses BenchmarkDotNet to measure and compare library performance. ## Alternatives Evaluation Criteria Libraries are evaluated based on: - Functionality - Licensing - Integration effort - Performance