This first assignment was designed to ensure that students have working OpenCV setups, and understand how to do basic pixel manipulation on images.
Method and Implementation
Per the instructions, my implementation takes an input image and outputs it in (1) grayscale, and (2) flipped horizontally. It additionally outputs (3) the image rotated 45 degrees around the Z axis.
My code implements the following functions:
unsigned i2uabs(int z): Converts a signed integer to an unsigned integer
unsigned char* imgcopy(unsigned char* imgdata, unsigned imgdatalength): Creates a copy of the specified image data array
void grayscaleConvert(unsigned char* imgdata, unsigned imgdatalength, unsigned imgwidth, unsigned bpp): Converts the specified image data to grayscale
void hflipTransform(unsigned char* imgdata, unsigned imgdatalength, unsigned imgwidth, unsigned bpp): Flips the specified image data horizontally about its center
void zrotTransform(unsigned char* imgdata, unsigned imgdatalength, unsigned imgwidth, unsigned bpp, int degrees): Rotates the specified image data around its center by a given number of degrees
void writeImage(unsigned char* data, unsigned len, unsigned width, unsigned bpp, int opencvimagetype, const char* filename): Writes the specified image data to the specified filename
int main(): Reads the input image, and calls the needed functions to create and write the 3 desired output images.
|Conversion||Source Image||Result Image|
|(2) Horizontal Flip|
|(3) Z Rotate 45 degrees|
Discuss your method and results:
The code functions as-expected.
Given the simplicity of the assignment, there aren't any implementation details worth discussing here.
Credits and Bibliography
The following pages were used for reference:
https://answers.opencv.org/question/93302/save-png-with-imwrite-read-access-violation/ (accessed 1/29/2020)
https://en.wikipedia.org/wiki/Grayscale (accessed 1/29/2020)