Previous approaches to automatic border recognition in two-dimensional echocardiography have utilized off-line computer image analysis. In this paper, we describe a hardware technique for real-time endocardial edge detection during the echocardiographic examination. This technique is based on a new method of line-by-line compensation for ultrasound attenuation. The detected edges and composite edge images can be displayed alone or superimposed upon the usual echocardiographic display. To test the accuracy of our real-time technique, we obtained echocardiograms of excised hearts and compared real-time edges with edges manually traced by an experienced observer. Left ventricular cavity areas and endocardial perimeters derived from real-time edges correlated well with those derived from observer-defined edges.