TE091585 – Komputasi Grid. Outline. ❑ Image Processing Revisited. ❑ Random
Jitter. ❑ Implementation of Parallel Random Jitter. ❑ Result. TE091585 ...
Manycore Parallel Algorithm Parallel For Image Processing
Outline Image Processing Revisited Random Jitter Implementation of Parallel Random Jitter Result
TE091585 – Komputasi Grid
Outline Image Processing Revisited Random Jitter Implementation of Parallel Random Jitter Result
TE091585 – Komputasi Grid
Image Processing • Image defined by pixel with some uniform sampling
TE091585 – Komputasi Grid
Image Processing • Other Properties: – Can be multiple channel (RGB, HSV, etc.). – First coordinate (0,0) lie at left-top. – A several image processing technique are essentially embarrassingly parallel. – More easier to implement then other problem.
Outline Image Processing Revisited Random Jitter Implementation of Parallel Random Jitter Result
TE091585 – Komputasi Grid
Random Jitter • Random Jitter: – A filter that can create oil painting effect.
TE091585 – Komputasi Grid
Random Jitter • Random Jitter Algorithm – Given image I – Copy image I to output image O – For each pixel • Compute random movement for current pixel in image I • If the movement not outside of the image then move current pixel in image I to new coordinate in image O
– End for
TE091585 – Komputasi Grid
Random Jitter • Must do: – Decide maximum movement of the pixel – The movement must remain in the image (0,0) to (width,height)
TE091585 – Komputasi Grid
Outline Image Processing Revisited Random Jitter Implementation of Parallel Random Jitter Result
TE091585 – Komputasi Grid
Implementation • Use OpenCV to reduce complexity • We still use parallel for to implement parallel random jitter • As usual, we test system with different image resolution and plot the speed-up over serial code.
TE091585 – Komputasi Grid
Serial Implementation int tx = img->width/2, ty = img->height/2; float PI = 3.141527f, DRAD = 180.0f / PI; RgbImage rgbimg(img); RgbImage rgbimgout(imgout); for(int y = 0; y < img->height; y++) { for(int x = 0; x < img->width; x++) { if (x == 0 || y == 0 || x == img->width-1 || y == img->height-1) rgbimgout[y][x] = rgbimg[y][x]; int xx = x + (rand() % 7) - 3; int yy = y + (rand() % 7) - 3; if (xx < 0) xx = 0; if (xx >= img->width) xx = img->width-1; if (yy < 0) yy = 0; if (yy >= img->height) yy = img->height-1; rgbimgout[yy][xx] = rgbimg[y][x]; } } TE091585 – Komputasi Grid
Parallel Implementation int tx = img->width/2, ty = img->height/2; float PI = 3.141527f, DRAD = 180.0f / PI; RgbImage rgbimg(img); RgbImage rgbimgout(imgout); #pragma omp parallel for shared(rgbimg, rgbimgout) for(int y = 0; y < img->height; y++) { for(int x = 0; x < img->width; x++) { if (x == 0 || y == 0 || x == img->width-1 || y == img->height-1) rgbimgout[y][x] = rgbimg[y][x]; int xx = x + (rand() % 7) - 3; int yy = y + (rand() % 7) - 3; if (xx < 0) xx = 0; if (xx >= img->width) xx = img->width-1; if (yy < 0) yy = 0; if (yy >= img->height) yy = img->height-1; rgbimgout[yy][xx] = rgbimg[y][x]; } } TE091585 – Komputasi Grid
Outline Image Processing Revisited Random Jitter Implementation of Parallel Random Jitter Result
TE091585 – Komputasi Grid
Testing Environments • Use 2 PC with 2 processor and 4 processor for comparison. • Use 4 different image resolution (256x256, 512x512, 1024x1024, 2048x2048). • Use 2 different number of thread (default and 10 thread).
TE091585 – Komputasi Grid
Result Speed-Up Random Jitter 3.5
3
Speed-Up
2.5
2 2P+Def.Thread 2P+10Thread
1.5
4P+Def.Thread
4P+10Thread
1
0.5
0 256
512
1024
Resolusi Image
TE091585 – Komputasi Grid
2048
Result • 2P+Def.Thread = 2 Processor with default thread. • 2P+10Thread = 2 Processor with 10 thread. • 4P+Def.Thread = 4 Processor with default thread. • 4P+10Thread = 4 Processor with 10 thread.