With shorter wavelengths than microwaves and greater penetration depth than infrared light, waves in the terahertz spectrum offer unique material testing opportunities. Terahertz technology offers non-invasive and non-destructive testing in the form of spectroscopy and imaging. The most used systems for terahertz imaging are time-domain spectroscopy systems. However, frequency domain spectroscopy systems could offer excellent frequency resolution and be more suitable for biomedical applications. Terahertz imaging based on frequency domain spectroscopy systems is slow, and suffers from frequency tuning errors. A novel one-dimensional imaging principle is presented in this paper. In addition, frequency range optimization based on convolutional neural networks and occlusion sensitivity is utilized for frequency range optimization. Frequency range optimization is used to determine the optimal frequency range for data acquisition. The optimal frequency range or bandwidth should be wide enough for effective phase detection, and should be at the intersection of several spectral footprints in the observed medium. The intersection of spectral footprints is estimated using the proposed frequency range optimization algorithm based on a convolutional neural network and occlusion sensitivity algorithm. The proposed algorithm selects the most sensitive frequency band of THz spectrum automatically, and enables very fast acquisitions for object inspection and classification.