Colorectal cancer (CRC) is a prevalent and life-threatening malignancy, demanding early diagnosis and effective treatment for improved patient outcomes. Accurate segmentation of colon cancer in medical images is a challenging task due to the complexity of its morphology and limited annotated data availability. This paper presents an efficient approach for colon cancer segmentation and image synthesis, combining an Attention U-Net and Pix2Pix Generative Adversarial Network (Pix2Pix-GAN) guided by Sine Cosine Algorithm (SCA) for hyperparameter tuning within the GAN framework. The utilization of SCA plays a pivotal role in optimizing the delicate balance between generator and discriminator dynamics, resulting in enhanced convergence and stability. Our method achieved state-of-the-art results with a mean Dice score of 0.9514, mean Intersection over Union of 0.9123, F beta score of 0.9636, and similarity index of 0.9430 outperforming existing methods. Moreover, the Mean Absolute Error reached a minimal value of 0.01583. This proposed approach shows promise in enhancing the accuracy and robustness of colon cancer diagnosis and treatment which could lead to better diagnosis and treatment of colon cancer.