Difference between revisions of "Team Z"
(→Project Image Spitfire) |
(→Project Image Spitfire) |
||
Line 25: | Line 25: | ||
} | } | ||
} | } | ||
− | |||
// Convert the unsigned characters to integers | // Convert the unsigned characters to integers | ||
Line 37: | Line 36: | ||
image.setPixelVal(i, j, val); | image.setPixelVal(i, j, val); | ||
} | } | ||
+ | |||
+ | IMAGE Rotation | ||
+ | |||
+ | <pre>// goes through the array of the oldImage, uses the formulas to find where the pixel should go // then puts the old pixel value into the new pixel position on the tempImage for(int r = 0; r < rows; r++) { for(int c = 0; c < cols; c++) { r1 = (int) (r0 + ((r - r0) * cos(rads)) - ((c - c0) * sin(rads))); c1 = (int) (c0 + ((r - r0) * sin(rads)) + ((c - c0) * cos(rads))); if(inBounds(r1,c1)) // makes sure the new pixel location is in bounds, { tempImage.pixelVal[r1][c1] = oldImage.pixelVal[r][c]; } } } for(int i = 0; i < rows; i++) { for(int j = 0; j < cols; j++) { if(tempImage.pixelVal[i][j] == 0) tempImage.pixelVal[i][j] = tempImage.pixelVal[i][j+1]; } }</pre><br> | ||
= Assignment 2 = | = Assignment 2 = | ||
= Assignment 3 = | = Assignment 3 = |
Revision as of 21:26, 10 February 2013
Contents
Team Z
Team Members
Assignment 1
Project Image Spitfire
I am using the Image Processor code that Natalia found as the source code to find the CUDA optimization possibilities. The image processor includes various functions like displaying image, getting sub image, enlarge image, shrink image, reflect image, translate image, image rotation and image negative. The application uses lots of for looping to achieve its goal and this provide an opportunity to use the GPU to achieve output much faster and hence enhancing the application performance.
Some of the source code that can be enhanced is as follows.
Image::Image(int numRows, int numCols, int grayLevels)
/* Creates an Image of numRows x numCols and creates the arrays for it*/ {
N = numRows; M = numCols; Q = grayLevels; pixelVal = new int *[N]; for(int i = 0; i < N; i++) { pixelVal[i] = new int [M]; for(int j = 0; j < M; j++) pixelVal[i][j] = 0; }
}
// Convert the unsigned characters to integers
int val;
for(i=0; i<N; i++)
for(j=0; j<M; j++) { val = (int)charImage[i*M+j]; image.setPixelVal(i, j, val); }
IMAGE Rotation
// goes through the array of the oldImage, uses the formulas to find where the pixel should go // then puts the old pixel value into the new pixel position on the tempImage for(int r = 0; r < rows; r++) { for(int c = 0; c < cols; c++) { r1 = (int) (r0 + ((r - r0) * cos(rads)) - ((c - c0) * sin(rads))); c1 = (int) (c0 + ((r - r0) * sin(rads)) + ((c - c0) * cos(rads))); if(inBounds(r1,c1)) // makes sure the new pixel location is in bounds, { tempImage.pixelVal[r1][c1] = oldImage.pixelVal[r][c]; } } } for(int i = 0; i < rows; i++) { for(int j = 0; j < cols; j++) { if(tempImage.pixelVal[i][j] == 0) tempImage.pixelVal[i][j] = tempImage.pixelVal[i][j+1]; } }