Due to the complex morphology and characteristic of retinal vessels, it remains challenging for most of the existing algorithms to accurately detect them. This paper proposes a supervised retinal vessels extraction scheme using constrained-based Nonnegative Matrix Factorization (NMF) and 3D modified Attention U-Net architecture. The proposed method detects the retinal vessels by three major steps. First, we perform Gaussian filter and Gamma correction on the Green channel of retinal images to suppress background noise and adjust the contrast of images. Then, the study develops a new within-class and between-class constrained NMF algorithms to extract neighborhood feature information of every pixel and reduce feature data dimension. By using these constraints, the method can effectively gather similar features within-class and discriminate features between-class to improve feature description ability for each pixel. Next, this study formulates segmentation task as a classification problem and solves it with a more contributing 3D modified Attention U-Net as a two-labels classifier for reducing computational cost. This proposed network contains an up-sampling to raise image resolution before encoding and revert image to its original size with a down-sampling after three max-pooling layers. Besides, the Attention Gate (AG) set in these layers contributes to more accurate segmentation by maintaining details while suppressing noises. Finally, the experimental results on two publicly available datasets STARE and DRIVE demonstrate better performance than most existing methods.