An image processing method for generating an omnifocal image on the basis of a plurality of captured images (D1, D2, D3, D4, D5), the method comprising the steps of: a) acquiring (S1-S5) a plurality of captured images (D1, D2, D3, D4, D5) by capturing an image of an object while changing a focal position (H1, H2, H3, H4, H5) along an optical axis; b) calculating definition for each pixel in each of said plurality of captured images (D1, D2, D3, D4, D5), said definition being an index indicating the sharpness of the image in the vicinity of said pixel; c) determining, for each coordinates in said omnifocal image to be generated, an image reference value by comparing said definition among corresponding pixels in each of said plurality of captured images (D1, D2, D3, D4, D5), the determined image reference value for each coordinates in said omnifocal image to be generated indicating a number of one of said captured images (D1, D2, D3, D4, D5) that is to be referenced for a luminance value of each coordinates in said omnifocal image to be generated, by setting the image reference value for each coordinates in said omnifocal image to be generated to the number of one of the plurality of captured images (D1, D2, D3, D4, D5) to which a pixel having a highest definition belongs; d) calculating a luminance value for each coordinates in said omnifocal image to be generated, being coordinates of interest, on the basis of a first luminance value and one or more second luminance values, the first luminance value being calculated by referencing the luminance value of said coordinates of interest in one of the plurality of captured images (D1, D2, D3, D4, D5) indicated by the image reference value of the coordinates of interest and the one or more second luminance values being calculated by referencing to a luminance value of the coordinates of interest in one of the plurality of captured images (D1, D2, D3, D4, D5) indicated by the image reference value of peripheral coordinates being in a distance to the coordinates of interest; and e) generating an omnifocal image by combining the calculated luminance values. a) acquiring (S1-S5) a plurality of captured images (D1, D2, D3, D4, D5) by capturing an image of an object while changing a focal position (H1, H2, H3, H4, H5) along an optical axis; b) calculating definition for each pixel in each of said plurality of captured images (D1, D2, D3, D4, D5), said definition being an index indicating the sharpness of the image in the vicinity of said pixel; c) determining, for each coordinates in said omnifocal image to be generated, an image reference value by comparing said definition among corresponding pixels in each of said plurality of captured images (D1, D2, D3, D4, D5), the determined image reference value for each coordinates in said omnifocal image to be generated indicating a number of one of said captured images (D1, D2, D3, D4, D5) that is to be referenced for a luminance value of each coordinates in said omnifocal image to be generated, by setting the image reference value for each coordinates in said omnifocal image to be generated to the number of one of the plurality of captured images (D1, D2, D3, D4, D5) to which a pixel having a highest definition belongs; d) calculating a luminance value for each coordinates in said omnifocal image to be generated, being coordinates of interest, on the basis of a first luminance value and one or more second luminance values, the first luminance value being calculated by referencing the luminance value of said coordinates of interest in one of the plurality of captured images (D1, D2, D3, D4, D5) indicated by the image reference value of the coordinates of interest and the one or more second luminance values being calculated by referencing to a luminance value of the coordinates of interest in one of the plurality of captured images (D1, D2, D3, D4, D5) indicated by the image reference value of peripheral coordinates being in a distance to the coordinates of interest; and e) generating an omnifocal image by combining the calculated luminance values.