Lung cancer, which has a high mortality and the greatest incidence worldwide, can be diagnosed with the aid of chest x-rays or computerized tomography (CT). Some computer-aided diagnosis (CAD) systems have been developed to help physicians diagnose lung cancer. In medical images, however, some nodules attached to the lung boundary are usually segmented as a part of the pleura or mediastinum. This causes these non-isolated nodules to be excluded from the lung parenchyma, which will influence the accuracy of CAD in nodule detection. To solve this problem, this article presents a method known as K-cosine corner detection to find the corner points on a boundary. These corner points are linked under defined criteria. Experimental results shows that a complete and accurate segmentation of lung parenchyma can be carried out, which demonstrates the feasibility of the proposed method.