Team Z

From CDOT Wiki
Revision as of 22:32, 10 February 2013 by Bapatel6 (talk | contribs) (Project Image Spitfire)
Jump to: navigation, search

Team Z

Team Members

  1. Bhrugesh Patel

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. Most of the code follows O(n2) notation with nested loops that can be paralleled using GPU and CUDA code.

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];
		}
	}


Assignment 2

Assignment 3