multiplicative scaling

45 阅读3分钟

and multiplicative scaling. By updating the individual pixel values in the image’s matrix, you can manipulate the
image in various ways to achieve the desired result. We will provide you with the starting code and required files
for the project.
Environment Setup
Code link:

  1. Set up visual studio code for C/C++: Visual Studio Code C/C++ setup.
  2. Download the code and set up your environment.
  3. Rename the file FIRSTNAME LASTNAME NETID with your first name, last name, and NETID.
  4. Test by running make. To learn more about make, read this Makefile tutorial.
    Part I (35 points)
    Create a templated class named Vector that serves as a fundamental component for implementing matrices in the
    image-processing library (from Project 1) that performs matrix operations on images. The Vector class should be
    capable of storing a collection of homogeneous data of any data type. Implement the class using either an array or
    a linked list, based on your preference. The class should provide the following functionalities:
  5. int getsize(): A member function that returns the size of the vector, i.e., the number of elements it
    contains.
  6. Copy constructor: A constructor that creates a new vector as a copy of an existing one.
  7. Assignment operator (operator=): An operator that allows the assignment of one vector to another.
  8. Destructor: A destructor that cleans up any resources the vector uses.
  9. Input and output stream operators (operator>> and operator<<): Operators that allow reading from and
    writing to input and output streams, respectively.
  10. Arithmetic operators (operator+, operator-, and operator*): Operators that allow addition, subtraction, and multiplication of vectors.
  11. Subscript operator (operator[]): An operator that provides access to individual elements of the vector
    based on their index.
  12. Additionally, implement any member functions as virtual if you believe they should be overrideable in derived classes. This class will later be used to create the Matrix class, which will be an essential part of the
    image-processing library.
  13. Constructors also need to be defined for the Vector object to be usable.
    2
    Part II (35 points)
    Create a new class named Matrix that represents a matrix of elements of type uint8 t. The Matrix class should
    utilize the 代 写multiplicative scalingVector class through composition to implement the matrix structure, where each row or column of
    the matrix is represented as an instance of the Vector class. The class should provide implementations for the
    following operators and member functions:
  14. Copy constructor
  15. Assignment operator (operator=)
  16. Destructor
  17. Input and output stream operators (operator>> and operator<<)
  18. Arithmetic operators (operator+, operator-, and operator*)
  19. Subscript operator (operator[])
    Additionally, implement the following new member functions in the Matrix class:
  20. int getrows(): A member function that returns the number of rows in the matrix.
  21. int getcols(): A member function that returns the number of columns in the matrix.
    The Matrix class will serve as an essential component in the image-processing library (from Project 1) that performs matrix operations on images. The composition of Vector instances allows the Matrix class to leverage the
    functionalities of the Vector class while maintaining the semantic distinction between vectors and matrices.
    Part III (30 points)
    Create a new Image class that inherits from the Matrix class and implements all the functions described in Project
  22. The Image class should have the following properties:
    • filePath: The file path for the image.
    • numChannels: The number of color channels (e.g., 3 for RGB images).
    • width: The width of the image in pixels.
    • height: The height of the image in pixels.
    The Image class should be capable of performing the following operations on images:
  23. Scaling an image
  24. Adding two images
  25. Subtracting two images
  26. Multiplying two images
    The operations for scaling, adding, subtracting, and multiplying images should be implemented as overloaded
    operators (+, -, and *).
    3
    Part IV (30 points) EXTRA CREDIT
    • Add a function called transpose() to the Matrix class. This function should generate the transpose of
    the original matrix, such that each element in the transposed matrix MT is given by the formula MT
    i j = Mji,
    where Mji is the element in the j-th row and i-th column of the original matrix M. The resulting matrix MT
    should have dimensions that are the transpose of the original matrix’s dimensions, i.e., if the original matrix
    M has dimensions m ⇥ n, the transposed matrix MT should have dimensions n ⇥ m.
    • Additionally, create a function called resize() in the Image class that uses the stb image resize library
    to resize an image and populates the Image object accordingly. The resize() function should take the
    original image of dimensions m ⇥ n (height m and width n) and produce a resized image of dimensions p ⇥ q
    (new height p and new width q), where p and q are the target dimensions for resizing. Use the functions
    provided by the stb image resize library to perform the resizing operation, preserving the aspect ratio

An illustration of the file structure is shown below:
The file organizational structure for this project is as follows:
• FIRSTNAME LASTNAME NETID
• Makefile
• src
– Image.cpp
4
– Image.h
– Matrix.cpp
– Matrix.h
– Vector.h
– main.cpp
• stb image
– stb image.h
– stb image resize.h
– stb image write.h

and visual content of the image while adjusting its size. The resized image should be stored in the Image
object.
You may want to write a main.cpp file that tests the Image class with real images, executing all the operationsimplemented in the previous parts of this project.Submission
Please zip your code and submit it via Canvas. You must include the file with your name and NETID (as specifiedin Section and your modified headers.
WX:codinghelp