Addressing the critical public health challenge of skin cancer, particularly melanoma and non-melanoma, this study focuses on enhancing early diagnosis through improved automatic segmentation of skin lesions in dermoscopic images. The researchers propose an optimized U-Net architecture that integrates advanced convolutional neural networks (CNNs) with backbone models such as ResNet50, VGG16, and MobileNetV2, specifically designed to handle the inherent variability and artifacts in dermoscopic imagery. The method's effectiveness was validated using the ISIC-2018 dataset, and our U-Net model incorporating the VGG16 backbone achieved notable improvements in segmentation accuracy, demonstrating an accuracy rate of 0.93. These results signify significant enhancements over existing methods, emphasizing the potential of the proposed approach in aiding precise skin cancer diagnosis and detection. This study makes a valuable contribution to dermatological imaging by presenting an advanced method that substantially boosts the accuracy of skin lesion segmentation, addressing a crucial need in public health.