An optical system for capturing images of a three-dimensional object , the optical system comprising a projector for structured illumination of the object , wherein the projector comprises: a light source , a grid mask positioned between the light source and the object for structured illumination of the object , characterized by a first element having a phase modulating mask positioned between the grid mask and the object to receive patterned light from the light source through the grid mask , wherein the first element is constructed and arranged such that a point spread function of the projector is substantially invariant over a wider range of depth of field of the grid mask than a point spread function of the projector without the first element , wherein the optical system further comprises a detector for detecting the object with structured illumination from the projector , a second-element having a second phase modulating mask located between the object and the detector such that a first image of the object and a second image of the grid mask on the detector have a larger depth of field than without the second element , wherein each of the first element and second element comprises a circularly symmetric element, and/or each of the first and second elements comprises a weakly non-separable function wherein especially the weakly non-separable function for the first element is expressed as P x y = ∑ i N ∑ j N α i x i + β j y j + γx i y i , the weakly non-separable function for the second element is expressed as P(X',Y') = ∑ i N ∑ j N α i − X ′ i + β j − Y ′ j + γ − X ′ i − Y ′ j , i and j are positive integers, wherein Y' axis is in the same direction as y axis, Z' axis is in the same direction as x axis, and X' axis is in the opposite direction of z axis. a light source , a grid mask positioned between the light source and the object for structured illumination of the object , characterized by a first element having a phase modulating mask positioned between the grid mask and the object to receive patterned light from the light source through the grid mask , wherein the first element is constructed and arranged such that a point spread function of the projector is substantially invariant over a wider range of depth of field of the grid mask than a point spread function of the projector without the first element , wherein the optical system further comprises a detector for detecting the object with structured illumination from the projector , a second-element having a second phase modulating mask located between the object and the detector such that a first image of the object and a second image of the grid mask on the detector have a larger depth of field than without the second element , wherein each of the first element and second element comprises a circularly symmetric element, and/or each of the first and second elements comprises a weakly non-separable function wherein especially the weakly non-separable function for the first element is expressed as P x y = ∑ i N ∑ j N α i x i + β j y j + γx i y i , the weakly non-separable function for the second element is expressed as P(X',Y') = ∑ i N ∑ j N α i − X ′ i + β j − Y ′ j + γ − X ′ i − Y ′ j , i and j are positive integers, wherein Y' axis is in the same direction as y axis, Z' axis is in the same direction as x axis, and X' axis is in the opposite direction of z axis. <EOS>