Objectives: To develop a better method for enhancing head MRI or CT images with the objective of suppressing irrelevant information during subsequent processing. Methods: To achieve this, two innovative image enhancement techniques, 'AHE' and 'Adaptive Gamma with CDF-based Geometric Transformation,' are combined. The proposed method is evaluated using a total of 76 MRI and 137 CT scan images obtained from the TCIA, OASIS, BCIIHM, and Brain metastases datasets. To tailor these methods for head MRI and CT images, two background masking algorithms have been introduced in this regard. Furthermore, the dark, grey, and white segments of the histogram are identified and geometrically transformed into square areas, followed by a gamma transformation applied to each transformed segment. Finally, a combination of global gamma transformation and AHE is applied to achieve the final enhancement. The proposed method is compared with other state-of-the-art techniques based on evaluation parameters such as "contrast, "correlation, and "entropy. Findings: Both qualitative and quantitative analysis exhibit how the proposed method has better enhancement capability than the CLAHE, AGC, and EGC methods. Our approach yields the highest average contrast, correlation, and entropy values for MRI, measuring 0.522319529, 0.957321634, and 5.585280467, respectively. For CT images, the suggested approach produces the maximum entropy value, 3.472600537, and the average contrast, 0.151943828, which is just less than CLAHE. The average correlation for CT, 0.98799312, is also a hair less than EGC. These results suggest that the proposed method could potentially make the details and structures in the MRI and CT more distinguishable. Novelty : The suggested approach uses a 2D geometric transformation for enhancing contrast of brain CT/MRI images and two robust head masking processes for removing noise in the background. The comparative analysis shows that the proposed method exhibits superior contrast enhancement capability compared to the other three methods being compared.