A computer-implemented method comprising: obtaining an MxN array of pixel values of an image; determining, based on lookup tables, a weight selection value for position x,y in the MxN array; and using the weight selection value to obtain a weight value for use in a filter for bilateral filtering the image, wherein determining the weight selection value omega x,y for position x,y comprises: a) retrieving a previously determined weight selection value for position x,y-1, denoted as omega x,y-1; b) retrieving a previously determined alpha value, a, for position x,y-1; c) calculating a delta value, d; and d) calculating omega x,y = omega x,y-1 - a + d, wherein calculating d comprises: i) retrieving a first previously determined value, omega_row, wherein omega_row is equal to [abs(A x-2,y+1 - A x-2,y+2) + abs(A x-1,y+1 - A x-2,y+2) + abs(A x,y+1 - A x,y+2)]; ii) retrieving a second previously determined value, alpha_row, wherein alpha_row is equal to abs(A x-2,y+1 - A x-2,y+2); and iii) calculating d = omega_row - alpha_row + abs(A x+1,y+1 - A x+1,y+2), wherein A x+1,y+1 is the value stored in position x+1,y+1 of the array, A x+1,y+2 is the value stored in position x+1,y+2 of the array, A x-2,y+1 is the value stored in position x-2,y+1 of the array, A x-2,y+2 is the value stored in position x-2,y+2 of the array, A x-1,y+1 is the value stored in position x-1,y+1 of the array, A x,y+1 is the value stored in position x,y+1 of the array and A x,y+2 is the value stored in position x,y+2 of the array. obtaining an MxN array of pixel values of an image; determining, based on lookup tables, a weight selection value for position x,y in the MxN array; and using the weight selection value to obtain a weight value for use in a filter for bilateral filtering the image, wherein determining the weight selection value omega x,y for position x,y comprises: a) retrieving a previously determined weight selection value for position x,y-1, denoted as omega x,y-1; b) retrieving a previously determined alpha value, a, for position x,y-1; c) calculating a delta value, d; and d) calculating omega x,y = omega x,y-1 - a + d, a) retrieving a previously determined weight selection value for position x,y-1, denoted as omega x,y-1; b) retrieving a previously determined alpha value, a, for position x,y-1; c) calculating a delta value, d; and d) calculating omega x,y = omega x,y-1 - a + d, wherein calculating d comprises: i) retrieving a first previously determined value, omega_row, wherein omega_row is equal to [abs(A x-2,y+1 - A x-2,y+2) + abs(A x-1,y+1 - A x-2,y+2) + abs(A x,y+1 - A x,y+2)]; ii) retrieving a second previously determined value, alpha_row, wherein alpha_row is equal to abs(A x-2,y+1 - A x-2,y+2); and iii) calculating d = omega_row - alpha_row + abs(A x+1,y+1 - A x+1,y+2), wherein A x+1,y+1 is the value stored in position x+1,y+1 of the array, A x+1,y+2 is the value stored in position x+1,y+2 of the array, A x-2,y+1 is the value stored in position x-2,y+1 of the array, A x-2,y+2 is the value stored in position x-2,y+2 of the array, A x-1,y+1 is the value stored in position x-1,y+1 of the array, A x,y+1 is the value stored in position x,y+1 of the array and A x,y+2 is the value stored in position x,y+2 of the array. i) retrieving a first previously determined value, omega_row, wherein omega_row is equal to [abs(A x-2,y+1 - A x-2,y+2) + abs(A x-1,y+1 - A x-2,y+2) + abs(A x,y+1 - A x,y+2)]; ii) retrieving a second previously determined value, alpha_row, wherein alpha_row is equal to abs(A x-2,y+1 - A x-2,y+2); and iii) calculating d = omega_row - alpha_row + abs(A x+1,y+1 - A x+1,y+2), wherein A x+1,y+1 is the value stored in position x+1,y+1 of the array, A x+1,y+2 is the value stored in position x+1,y+2 of the array, A x-2,y+1 is the value stored in position x-2,y+1 of the array, A x-2,y+2 is the value stored in position x-2,y+2 of the array, A x-1,y+1 is the value stored in position x-1,y+1 of the array, A x,y+1 is the value stored in position x,y+1 of the array and A x,y+2 is the value stored in position x,y+2 of the array.