郭昱辰, 簡子昕
Welcome to the documentation for the Chisel-Based Pixel-Art Scaling Hardware Accelerator. This project represents the final assignment for the Computer Architecture course (113-1 Semester). In its initial version, the accelerator facilitates image conversion and incorporates several fundamental features. Future iterations will focus on enhancing performance through hardware acceleration.
Pixel Art is a digital art form characterized by the meticulous creation and editing of images at the pixel level, commonly utilized in gaming and graphic design. As image resolutions escalate, the efficient scaling of pixel art poses significant challenges. This project endeavors to design a hardware accelerator using the Chisel language to achieve high-quality pixel art scaling. The current version (1.0) encompasses image conversion and several essential functionalities, laying the groundwork for future enhancements aimed at optimizing performance through hardware acceleration.
Before engaging with this project, ensure you possess the following knowledge and tools:
The objective of this project is to design a Chisel-based hardware accelerator capable of efficiently scaling pixel art images. The key functionalities implemented in this version include:
This documentation will delve into the implementation specifics of each module, providing a comprehensive analysis of the project's components.
RGB Separation and Grayscale Conversion: Segregates the input 24-bit RGB pixel into individual R, G, and B components. Converts these components to grayscale using a standard formula to streamline the subsequent edge detection process.
Sobel Algorithm Application: Implements the Sobel operator to compute horizontal (Gx) and vertical (Gy) gradients, which are essential for edge detection.
Gradient Magnitude and Direction Determination: Calculates the gradient magnitude by summing the absolute values of Gx and Gy. If the magnitude surpasses a predefined threshold, the pixel is classified as an edge, and its direction (horizontal, vertical, diagonal) is ascertained based on the relative magnitudes of Gx and Gy.
Interpolation Strategy: Selects appropriate interpolation methods based on the detected edge direction (horizontal, vertical, diagonal). Currently utilizes linear interpolation as a foundational approach, with placeholders for more sophisticated strategies.
Intelligent Interpolation: Leverages edge strength to determine the necessity of interpolation. If the edge strength is below a certain threshold, the current pixel is directly propagated to preserve image fidelity.
Line Buffer Management: Utilizes three line buffers (previous, current, next) to store sequential lines of image data. Manages column and row indices to track the current position within the image matrix.
Neighboring Pixel Extraction: Retrieves the eight neighboring pixels surrounding the current pixel, handling boundary conditions by padding with zeros where necessary to avoid accessing invalid memory regions.
Edge Detection and Interpolation: Feeds the current pixel and its neighbors into the EnhancedEdgeDetector
module to identify edges. The resultant edge direction and strength are then passed to the EnhancedPixelInterpolator
module to perform intelligent interpolation based on the detected edge characteristics.
Read Scaling Factor: Prompts the user to input the desired scaling factor, ensuring it falls within the acceptable range (1 to 4).
Read Image and Convert to 2D Array: Utilizes Scala's ImageIO
to load a PNG/JPG image and transform it into a two-dimensional array representing pixel data in 24-bit RGB format.
Write Output Matrix Back to Image: Converts the processed two-dimensional pixel array back into an image format and saves it to the specified output path.
Prepare Data: Reads the input image, determines the dimensions of the scaled output image based on the scaling factor, and initializes the output matrix accordingly.
Simulation Using RawTester: Employs RawTester
to simulate the EnhancedPixelArtScaler
module. Inputs image data into the module, simulates hardware operations, and aggregates the output pixels into the output matrix.
Write Back Image File: Saves the scaled pixel data as a new image file, completing the scaling process.
Follow these steps to run the project:
Set Up the Development Environment:
Install Scala and SBT (Scala Build Tool)**: Ensure that Scala and SBT are installed on your system. Refer to the Scala installation guide and the SBT installation instructions for detailed steps.
Install Chisel and Dependencies**: Set up Chisel by following the official Chisel installation guide.
Prepare Input Image:
/home/yckuo/桌面/chisel-book/src/main/scala/Pixel-art scaling Accelerator/Lenna.png
.Compile and Run:
PixelArtScale
main program and input the desired scaling factor (e.g., 2 for 2x scaling).View Output Results:
/home/yckuo/桌面/chisel-book/src/main/scala/Pixel-art scaling Accelerator/output.png
.After running the program, you will obtain the scaled image. Below is an example comparison of the original and scaled images:
In this project, we successfully designed and implemented a Chisel-based pixel art scaling solution, focusing on the core Art Pixel functionality. The current implementation integrates edge detection and intelligent interpolation techniques to facilitate the scaling of pixel art images effectively. While the foundational features are operational, the present version does not yet leverage hardware acceleration, which remains a critical area for enhancement.
Future Enhancements Include:
Integration of Hardware Accelerators: Developing dedicated hardware accelerators to parallelize computations, thereby significantly accelerating the scaling process and improving overall performance.
Optimization of Interpolation Algorithms: Refining existing interpolation methods and incorporating advanced algorithms, such as the xBR algorithm, to further enhance image quality and scalability.
Expansion of Supported Scaling Factors: Extending the range of supported scaling factors to accommodate a wider variety of application requirements and use cases.
Hardware Resource Optimization: Streamlining module designs to minimize hardware resource consumption, ensuring efficient utilization and maximizing performance.
These enhancements aim to elevate the pixel art scaling solution's performance and versatility, establishing it as a robust and efficient tool for various digital applications. By focusing on hardware acceleration and algorithm optimization, future versions will deliver superior scalability and image fidelity, meeting the demanding needs of modern pixel art processing.