Skip to main content
edited tags
Link
200_success
  • 145.7k
  • 22
  • 191
  • 481
Improved formatting.
Source Link
Morwenn
  • 20.2k
  • 3
  • 69
  • 132

So far I've tried "Blocking" and and a few other things, but I can't seem to get it to run any faster.

mask_functionmask_function cannot be changed, but here is its code:

So far I've tried "Blocking" and and a few other things, but can't seem to get it to run any faster.

mask_function cannot be changed, but here is its code:

So far I've tried "Blocking" and a few other things, but I can't seem to get it to run any faster.

mask_function cannot be changed, but here is its code:

added mask_function
Source Link
Speerian
  • 213
  • 2
  • 9
 for(yy = 1; yy<height-1; yy+=4){ for(xx = 1; xx<width -1; xx+=4){ for (y = yy; y < 4+yy; y++){ for (x = xx; x < 4+xx; x++){ for (z = 0; z < 3; z++) {   tmp = mask_product(mask,a,x,y,z);   if (tmp>255) tmp = 255;   if (tmp<threshold) tmp = 0;   c[x][y][z] = 255-tmp; }}}}} 

mask_function cannot be changed, but here is its code:

int mask_product(int m[3][3], byte bitmap[MAX_ROW][MAX_COL][NUM_COLORS], int x, int y, int z) { int tmp[9]; int i, sum; // ADDED THIS LINE (sum = 0) TO FIX THE BUG sum = 0; tmp[0] = m[0][0]*bitmap[x-1][y-1][z]; tmp[1] = m[1][0]*bitmap[x][y-1][z]; tmp[2] = m[2][0]*bitmap[x+1][y-1][z]; tmp[3] = m[0][1]*bitmap[x-1][y][z]; tmp[4] = m[1][1]*bitmap[x][y][z]; tmp[5] = m[2][1]*bitmap[x+1][y][z]; tmp[6] = m[0][2]*bitmap[x-1][y+1][z]; tmp[7] = m[1][2]*bitmap[x][y+1][z]; tmp[8] = m[2][2]*bitmap[x+1][y+1][z]; for (i=0; i<9; i++) sum = sum + tmp[i]; return sum; } 
 for(yy = 1; yy<height-1; yy+=4){ for(xx = 1; xx<width -1; xx+=4){ for (y = yy; y < 4+yy; y++){ for (x = xx; x < 4+xx; x++){ for (z = 0; z < 3; z++) { tmp = mask_product(mask,a,x,y,z); if (tmp>255) tmp = 255; if (tmp<threshold) tmp = 0; c[x][y][z] = 255-tmp; }}}}} 
 for(yy = 1; yy<height-1; yy+=4){ for(xx = 1; xx<width -1; xx+=4){ for (y = yy; y < 4+yy; y++){ for (x = xx; x < 4+xx; x++){ for (z = 0; z < 3; z++) {   tmp = mask_product(mask,a,x,y,z);   if (tmp>255) tmp = 255;   if (tmp<threshold) tmp = 0;   c[x][y][z] = 255-tmp; }}}}} 

mask_function cannot be changed, but here is its code:

int mask_product(int m[3][3], byte bitmap[MAX_ROW][MAX_COL][NUM_COLORS], int x, int y, int z) { int tmp[9]; int i, sum; // ADDED THIS LINE (sum = 0) TO FIX THE BUG sum = 0; tmp[0] = m[0][0]*bitmap[x-1][y-1][z]; tmp[1] = m[1][0]*bitmap[x][y-1][z]; tmp[2] = m[2][0]*bitmap[x+1][y-1][z]; tmp[3] = m[0][1]*bitmap[x-1][y][z]; tmp[4] = m[1][1]*bitmap[x][y][z]; tmp[5] = m[2][1]*bitmap[x+1][y][z]; tmp[6] = m[0][2]*bitmap[x-1][y+1][z]; tmp[7] = m[1][2]*bitmap[x][y+1][z]; tmp[8] = m[2][2]*bitmap[x+1][y+1][z]; for (i=0; i<9; i++) sum = sum + tmp[i]; return sum; } 
Attempted to improve title (original is too generic)
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
Loading
Source Link
Speerian
  • 213
  • 2
  • 9
Loading