An image processing apparatus for performing an image processing for a target image being extracted from an obtained image to remove an influence of a background image by receiving designations of at least one foreground pixel and at least one background pixel, comprising: an ellipse calculating means that calculates a first ellipse by which the target image is approximated and that calculates a second ellipse by which a center candidate image of the target image is approximated; a center candidate deciding means that decides a center candidate (O A) of the target image, said center candidate (O A) being decided from an intersection point between a major axis (E2 A) and a minor axis (E2 B) of the second ellipse by which the center candidate image is approximated; a polygon calculating means that calculates a first polygon associated with the first ellipse and the center candidate (O A); a projective transformation matrix calculating means that calculates a projective transformation matrix which projectively transforms the first polygon into a second polygon (P1') associated with a third ellipse whose center is a point (O A ') where the center candidate (O A) is projectively transformed; and a transformation image obtaining means that projectively transforms the target image based on the projective transformation matrix and obtains a transformation image, wherein the polygon calculating means calculates the first polygon whose tangent points are intersection points between a straight line passing through the center candidate and the first ellipse, wherein the polygon calculating means assumes a straight line parallel to the major axis of the first ellipse as the straight line passing through the center candidate. an ellipse calculating means that calculates a first ellipse by which the target image is approximated and that calculates a second ellipse by which a center candidate image of the target image is approximated; a center candidate deciding means that decides a center candidate (O A) of the target image, said center candidate (O A) being decided from an intersection point between a major axis (E2 A) and a minor axis (E2 B) of the second ellipse by which the center candidate image is approximated; a polygon calculating means that calculates a first polygon associated with the first ellipse and the center candidate (O A); a projective transformation matrix calculating means that calculates a projective transformation matrix which projectively transforms the first polygon into a second polygon (P1') associated with a third ellipse whose center is a point (O A ') where the center candidate (O A) is projectively transformed; and a transformation image obtaining means that projectively transforms the target image based on the projective transformation matrix and obtains a transformation image, wherein the polygon calculating means calculates the first polygon whose tangent points are intersection points between a straight line passing through the center candidate and the first ellipse, wherein the polygon calculating means assumes a straight line parallel to the major axis of the first ellipse as the straight line passing through the center candidate.