A method for processing an image, comprising: obtaining depth-of-field data of an input image and obtaining a weight matrix of the input image based on the depth-of-field data; obtaining a product of a weight corresponding to a pixel in the weight matrix and a pixel value corresponding to the pixel in the input image and obtaining a weight image, wherein the product is the pixel value of the pixel in the weight image; obtaining a first horizontal summed area table corresponding to the weight matrix by performing a horizontal summing operation on the weight matrix and obtaining a second horizontal summed area table corresponding to the weight image by performing the horizontal summing operation on the weight image, wherein the horizontal summing operation refers to, obtaining a sum of the pixel value of a pixel and pixel value of pixels before the pixel and on the same row with the pixel; for each pixel outside a depth-of-field range, obtaining a blurring value corresponding to the pixel of the weight matrix based on the first horizontal summed area table and obtaining a first weighted blurring image corresponding to the weight matrix, and obtaining a blurring value corresponding to the pixel of the weight image based on the second horizontal summed area table and obtaining a second weighted blurring image corresponding to the weight image; and for each pixel outside the depth-of-field range, obtaining a ratio of the blurring value corresponding to the pixel in the second weighted blurring image to the blurring value corresponding to the pixel in the first weighted blurring image, and determining the ratio as the pixel value corresponding to the pixel in a target image; the target image being obtained by blurring the input image; wherein obtaining the weight matrix comprises: obtaining the weight matrix of the input image by setting weights of pixels within the depth-of-field range to zero and setting weights of pixels outside the depth-of-field range to a preset value based on the depth-of-field data. obtaining depth-of-field data of an input image and obtaining a weight matrix of the input image based on the depth-of-field data; obtaining a product of a weight corresponding to a pixel in the weight matrix and a pixel value corresponding to the pixel in the input image and obtaining a weight image, wherein the product is the pixel value of the pixel in the weight image; obtaining a first horizontal summed area table corresponding to the weight matrix by performing a horizontal summing operation on the weight matrix and obtaining a second horizontal summed area table corresponding to the weight image by performing the horizontal summing operation on the weight image, wherein the horizontal summing operation refers to, obtaining a sum of the pixel value of a pixel and pixel value of pixels before the pixel and on the same row with the pixel; for each pixel outside a depth-of-field range, obtaining a blurring value corresponding to the pixel of the weight matrix based on the first horizontal summed area table and obtaining a first weighted blurring image corresponding to the weight matrix, and obtaining a blurring value corresponding to the pixel of the weight image based on the second horizontal summed area table and obtaining a second weighted blurring image corresponding to the weight image; and for each pixel outside the depth-of-field range, obtaining a ratio of the blurring value corresponding to the pixel in the second weighted blurring image to the blurring value corresponding to the pixel in the first weighted blurring image, and determining the ratio as the pixel value corresponding to the pixel in a target image; the target image being obtained by blurring the input image; wherein obtaining the weight matrix comprises: obtaining the weight matrix of the input image by setting weights of pixels within the depth-of-field range to zero and setting weights of pixels outside the depth-of-field range to a preset value based on the depth-of-field data.