Percutaneous coronary intervention is a minimally invasive procedure that is usually performed under image guidance using X-ray angiograms in which coronary arteries are opacified with contrast agent. In X-ray images, 3D objects are projected on a 2D plane, generating semi-transparent layers that overlap each other. The overlapping of structures makes robust automatic information processing of the X-ray images, such as vessel extraction which is highly relevant to support smart image guidance, challenging. In this paper, we propose an automatic online layer separation approach that robustly separates interventional X-ray angiograms into three layers: a breathing layer, a quasi-static layer and a vessel layer that contains information of coronary arteries and medical instruments. The method uses morphological closing and an online robust PCA algorithm to separate the three layers. The proposed layer separation method ran fast and was demonstrated to significantly improve the vessel visibility in clinical X-ray images and showed better performance than other related online or prospective approaches. The potential of the proposed approach was demonstrated by enhancing contrast of vessels in X-ray images with low vessel contrast, which would facilitate the use of reduced amount of contrast agent to prevent contrast-induced side effects.