A medical system for imaging includes a processor (114) and memory (116) coupled to the processor. The memory includes an optical shape sensing module (115) configured to receive shape sensing data from a shape sensing system (104) coupled to a medical instrument (102). The shape sensing system is configured to measure a shape and position of the medical instrument. An image generation module (148) is configured to detect and digitally remove image artifacts of the medical instrument from a generated image based on at least the shape and the position of the medical instrument as measured by the shape sensing system.