Humans with COVID-19 have an infectious condition that affects the respiratory system. In addition to more serious conditions, headaches may be fatal for those who have the disease. Our difficulty with COVID-19 detection stems from the unreliability of computed tomography (CT) and magnetic resonance imaging (MRI) scans in identifying lung abnormalities. COVID-19 detection is a time-consuming process. In this research, a novel CODE NET model is proposed for the detection of COVID-19 virus from the gathered lung chest X-ray (CXR) images. The images are pre-processed utilizing an adaptive trilateral filter to improve the quality of the images. A reverse edge attention network (RE-Net) uses enhanced images to segment the CXR images for accurate virus detection. The segmented images are fed into a Link Net to extract relevant features and classify the COVID-19 cases. The classified cases are fed into the Grad-CAM model to generate heat maps for accurately detecting the virus. According to the result, the proposed model attains 99.75% of accuracy rate for the COVID-19 detection. The proposed CODE NET enhances the overall accuracy by 1.78%, 1.51%, and 2.20% over combined domain features-random forest (CDF-RF), Bayes-SqueezeNet, and bidirectional long short-term memory (Bi-LSTM) respectively.