Cortical surface extraction from magnetic resonance (MR) scans is a preliminary, yet crucial step in brain segmentation and analysis. Although there are many algorithms that address this problem, they often sacrifice execution speed for accuracy or they depend on many parameters that have to be tuned manually by an experienced practitioner. Therefore fast, accurate and autonomous cortical surface extraction algorithms are in high demand and they are being actively developed to enable clinicians to appropriately plan a treatment pathway and quantify response in patients with brain lesions based on precise image analysis. In this paper, we present an automated approach for cortical surface extraction from MR images based on 3D image morphology, connected component labeling and edge detection. Our technique allows for real-time processing of MR scans – an average study of 102 slices, each 512x512 pixels, takes approximately 768 ms to process (about 7 ms per slice) with known parameters. To automate the process of tuning the algorithm parameters, we developed a genetic algorithm for this task. Experimental study performed using real-life MR brain images revealed that the proposed algorithm offers very high-quality cortical surface extraction, it works in real-time, and it is competitive with the state of the art.