A computer-implemented method of image processing, comprising: - receiving at least one video frame of a video sequence, the at least one video frame comprising at least one foreground subject and a background; and - processing said at least one video frame so as to separate said at least one foreground subject from said background; wherein said processing includes: - obtaining a reference image including said background; - comparing the at least one video frame to the reference image; and - generating a pixel mask as a result of said comparison, said pixel mask indicating whether a pixel of the at least one video frame belongs to the foreground subject or to the background, - at least partially determining edges of said at least one foreground subject in said at least one video frame; - modifying the pixel mask based on the determined foreground subject edges, wherein said at least partially determining edges of said at least one foreground subject in said at least one video frame comprises: - determining edges in the at least one video frame; - determining edges in the reference image; - comparing the determined edges of the at least one video frame with the determined edges of the reference image, - said comparing the determined edges comprises subtracting pixel-by-pixel the edges determined in the reference image from the edges determined in the at least one video frame, characterized in that said at least partially determining edges of said at least one foreground subject in said at least one video frame comprises identifying, based on a sign of the result of said subtracting, pixels of the video frame that: - belong to a determined edge in the at least one video frame and not to a determined edge in the reference image, and pixels that - belong to a determined edge in the reference image and not to a determined edge in the at least one video frame; and in that it further comprises - applying morphological closing to the modified pixel mask, wherein the morphological closing operation is controlled by said edges of the foreground subject. - receiving at least one video frame of a video sequence, the at least one video frame comprising at least one foreground subject and a background; and - processing said at least one video frame so as to separate said at least one foreground subject from said background; - obtaining a reference image including said background; - comparing the at least one video frame to the reference image; and - generating a pixel mask as a result of said comparison, said pixel mask indicating whether a pixel of the at least one video frame belongs to the foreground subject or to the background, - at least partially determining edges of said at least one foreground subject in said at least one video frame; - modifying the pixel mask based on the determined foreground subject edges, wherein said at least partially determining edges of said at least one foreground subject in said at least one video frame comprises: - determining edges in the at least one video frame; - determining edges in the reference image; - comparing the determined edges of the at least one video frame with the determined edges of the reference image, - said comparing the determined edges comprises subtracting pixel-by-pixel the edges determined in the reference image from the edges determined in the at least one video frame, - belong to a determined edge in the at least one video frame and not to a determined edge in the reference image, and pixels that - belong to a determined edge in the reference image and not to a determined edge in the at least one video frame; and in that it further comprises - applying morphological closing to the modified pixel mask, wherein the morphological closing operation is controlled by said edges of the foreground subject. - applying morphological closing to the modified pixel mask, wherein the morphological closing operation is controlled by said edges of the foreground subject.