Modern radio telescopes are favouring densely packed array layouts with large numbers of antennas (N A 1000). Since the complexity of traditional correlators scales as O(N 2 A ), there will be a steep cost for realizing the full imaging potential of these powerful instruments. Through our generic and efficient E-field Parallel Imaging Correlator (EPIC), we present the first software demonstration of a generalized direct imaging algorithm, namely, the Modular Optimal Frequency Fourier (MOFF) imager. Not only does it bring down the cost for dense layouts to O(N A log 2 N A ) but can also image from irregular layouts and heterogeneous arrays of antennas. EPIC is highly modular, parallelizable, implemented in object-oriented Python, and publicly available. We have verified the images produced to be equivalent to those from traditional techniques to within a precision set by gridding coarseness. We have also validated our implementation on data observed with the Long Wavelength Array (LWA1). We provide a detailed framework for imaging with heterogeneous arrays and show that EPIC robustly estimates the input sky model for such arrays. Antenna layouts with dense filling factors consisting of a large number of antennas such as LWA, the Square Kilometre Array, Hydrogen Epoch of Reionization Array, and Canadian Hydrogen Intensity Mapping Experiment will gain significant computational advantage by deploying an optimized version of EPIC. The algorithm is a strong candidate for instruments targeting transient searches of Fast Radio Bursts (FRB) as well as planetary and exoplanetary phenomena due to the availability of high-speed calibrated time-domain images and low output bandwidth relative to visibility-based systems.