Changes

Jump to: navigation, search

Three-Star

482 bytes added, 08:31, 21 February 2018
Image Profiling
==== Image Profiling ====
Chosen to profile image profiling as shown here: http://www.dreamincode.net/forums/topic/76816-image-processing-tutorial/ , using the sample programs (main/image.h/image.cpp)
 
Slightly modified main.cpp to accomodate larger images.
 
Had to expand a PGM image (to about 1~MB size) to return any meaningful result (Using a regular sized PGM image of 11KB yielded absolutely no meaningful results to the human eye - all 0's on the flat profile/call graph)
 
Rotated and negated the image.
 
>g++ -g -O2 -pg -omain main.cpp
>main baboonsizetwo
>gprof -p -b main>main.flt
 
The results of the flat profile:
Out of all the functions tested, reflectImage has rotateImage takes up the largest ms/callamount of time. Below is the code for reflectImagerotateImage:
//void Image::reflectImagerotateImage(bool flagint theta, Image& oldImage)/*based on users input and rotates it around the center of the image.*/
{
int r0, c0; int r1, c1; int rows, cols; rows = oldImage.N; int cols = oldImage.M; Image tempImage(rows, cols, oldImage.Q); if float rads = (flag theta * 3.14159265)/180.0; r0 = rows / 2; c0 =cols / 2; for(int r = true0; r < rows; r++) //horizontal reflection
{
for(int i c = 0; i c < rowscols; ic++)
{
forr1 = (int j ) (r0 + ((r - r0) * cos(rads)) - ((c - c0) * sin(rads))); c1 = 0; j < cols; j(int) (c0 +((r - r0) * sin(rads)) +((c - c0)* cos(rads))); if(inBounds(r1,c1)) { tempImage.pixelVal[rows - (i + 1)r1][jc1] = oldImage.pixelVal[ir][jc]; }
}
}
else //vertical reflection for(int i = 0; i < rows; i++)
{
for(int i j = 0; i j < rowscols; ij++)
{
forif(int tempImage.pixelVal[i][j ] == 0; j < cols; j++) tempImage.pixelVal[i][cols - (j + 1)] = oldImagetempImage.pixelVal[i][j+1];
}
}
oldImage = tempImage;}
122
edits

Navigation menu