Diabetic Retinopathy is one of the leading causes of blindness in developed countries. Hard exudates have been found to be one of the most prevalent earliest clinical signs of retinopathy. Thus, automatic detection of hard exudates from retinal images is clinically significant. In this study, an automatic method to detect hard exudates is proposed. The algorithm is based on mixture models to dynamically threshold the images in order to separate exudates from background. A postprocessing technique, based on edge detection, is applied to distinguish hard exudates from cotton wool spots and other artefacts. We prospectively assessed the algorithm performance using a database of 80 retinal images with variable colour, brightness, and quality. The algorithm obtained a sensitivity of 90.2\% and a positive predictive value of 96.8\% using a lesion-based criterion. The image-based classification accuracy is also evaluated obtaining a sensitivity of 100\% and a specificity of 90\%.