We study the vortex structure in a Pb film deposited on top of a periodic array of ferromagnetic square microrings by combining two high-resolution imaging techniques: Bitter decoration and scanning Hall-probe microscopy (SHPM). The periodicity and strength of the magnetic pinning potential generated by the square microrings are controlled by the magnetic history of the template. When the square rings are in the magnetized dipolar state, known as the onion state, the strong stray field generated at the domain walls prevents the decoration of vortices. SHPM images show that the stray field generated by the dipoles is much stronger than the vortex field, in agreement with the results of simulations. Real-space vortex imaging has revealed that in the onion state, the corners of the square rings act as effective pinning centers for vortices.