Changes

Jump to: navigation, search

GroupNumberUndefined

1,629 bytes added, 16:37, 26 March 2017
Assignment 2
=== Assignment 2 ===
For assignment two we will be doing image processing.Choose to do the function enlarge() which basically makes the given image bigger. This is it's current implementation : void Image::enlargeImage(int value, Image& oldImage)/*enlarges Image and stores it in tempImage, resizes oldImage and stores the larger image in oldImage*/{ int rows, cols, gray; int pixel; int enlargeRow, enlargeCol; rows = oldImage.N * value; cols = oldImage.M * value; gray = oldImage.Q; Image tempImage(rows, cols, gray); for(int i = 0; i < oldImage.N; i++) { for(int j = 0; j < oldImage.M; j++) { pixel = oldImage.pixelVal[i][j]; enlargeRow = i * value; enlargeCol = j * value; for(int c = enlargeRow; c < (enlargeRow + value); c++) { for(int d = enlargeCol; d < (enlargeCol + value); d++) { tempImage.pixelVal[c][d] = pixel; } } } } oldImage = tempImage;} And this is the kernal implementation : __global__ void enlarge(int* pixelArr, const int* oldArray, int ni, int nj){ int i = blockIdx.x * blockDim.x + threadIdx.x; int j = blockIdx.y * blockDim.y + threadIdx.y; if (i < ni && j < nj) { int pixel = oldArray[i * nj + j]; pixelArr[(i * (nj*2) + j)*2] = pixel; pixelArr[(i * (nj*2) + j) * 2 + 1] = pixel; pixelArr[(i * (nj*2) + j) * 2 + nj*2] = pixel; pixelArr[(i * (nj*2) + j) * 2 + nj*2 + 1] = pixel; }} 
=== Assignment 3 ===
62
edits

Navigation menu