Open main menu

CDOT Wiki β

Changes

N/A

1,299 bytes added, 22:08, 15 February 2019
Assignment 1
The code uses standard libraries to handle images in the PGM format. It is a fairly straight forward program that intakes a number of images as command-line arguments, with the first being the image to edit, and provides the user some options to process the image, outputting the result to one of the provided image paths. The one thing I noticed the program lacks is a method for converting images to PGM, considering the program requires it. Therefore, for my testing of the program, I took a JPEG image and converted it to PGM using an online method found here: [https://www.files-conversion.com/image/pgm Dan's Tools - Convert Files]. Providing just the one image as a command-line argument only yielded 4 options that include getting/setting the values of pixels and getting other information. Looking through the code I knew there was more to it, but the method to process an image using the program required 2 arguments: first is the original image, second is the output image. With these provided, the program allows the user to rotate, invert/ reflect, enlarge, shrink, crop, translate, and negate.
 The code is found on the site, near the end of the article. To run it, I made a Makefile. The code downloaded and borrowed from the site are stored as text files, so I renamed them as .cpp and .h files within the Linux environment. Here are the files for ease of access: [[File:main.cpp.txt]] | [[File:image.h.txt]] | [[File:image.cpp.txt]]Also, here is the Makefile:
#Makefile for A1 - Image Processing
0.00 0.61 0.00 1 0.00 0.00 _GLOBAL__sub_I__ZN5ImageC2Ev
0.00 0.61 0.00 1 0.00 0.00 Image::Image(Image const&)
 
 
A second run of the program, with me enlarging the image, rotating, translating, and negating the image resulted in a time of:
 
real 1m0.968s
user 0m0.295s
sys 0m0.297s
 
And a Flat profile of:
 
% cumulative self self total
time seconds seconds calls ms/call ms/call name
33.37 0.14 0.14 6 23.36 23.36 Image::operator=(Image const&)
26.22 0.25 0.11 5 22.02 22.02 Image::Image(int, int, int)
14.30 0.31 0.06 writeImage(char*, Image&)
14.30 0.37 0.06 Image::rotateImage(int, Image&)
7.15 0.40 0.03 Image::enlargeImage(int, Image&)
2.38 0.41 0.01 Image::reflectImage(bool, Image&)
2.38 0.42 0.01 Image::translateImage(int, Image&)
0.00 0.42 0.00 6 0.00 0.00 Image::~Image()
0.00 0.42 0.00 1 0.00 0.00 _GLOBAL__sub_I__ZN5ImageC2Ev
0.00 0.42 0.00 1 0.00 0.00 Image::Image(Image const&)
'''Conclusion:'''
The Ignoring the real time spent, the majority of time is spent in the equals operator function and the class constructor, most likely because the image is constantly being manipulated, read from, and being copied to and from temporary storage for ease of use and object safety. Other than the basic functions (like read/write), it looks like the rotate and enlarge functions take a larger amount of time, which could mean that, if they were to be parallelized, it could positively affect the run time. My discernment of the big-O notation for the rotate function is O(n^2) which shows a quadratic growth rate, whereas the enlarge function had a notation of O(n^3) or greater. The reason for the rotate function having a longer run-time could be due to the fact that I enlarged the image before rotating it, but the notations don't lie. Personally, I'd say that this application is not the best for parallelization because of its simplicity in handling the images, but I can definitely see how one or more of the functions in the program can be parallelized. Some of the issues posed in making the program parallel is centered upon the image needing to be accessible to every other function, and, considering that the image is being processed, it would be constantly modified and read from. I simple terms, I think that, if multiple threads were running to quicken the program, the computation of the image could lead to errors in processing resulting in a corrupted image, distortions, and things of the sort. I may be wrong in this thought, but, to my knowledge, not being to avoid such issues makes this program somewhat difficult to safely parallelize.
=== Assignment 2 ===
=== Assignment 3 ===
5
edits