In the ultrasonic tomographic images, the heart wall cannot be distinguished from the cardiac lumen automatically using only the echogenicity, which corresponds to the amplitude of the RF echo, because the echogenicity inside the heart wall is as low as that in the lumen. In this paper ultrasonic RF echoes from the heart wall and lumen were analyzed in frequency domain in order to distinguish the heart wall from the lumen automatically. Temporal change in complex frequency spectra was evaluated using magnitude-squared coherence function. The coherence function of the RF signal scattered from the interventricular septum (IVS) is high. In contrast, the coherence function in the right ventricle (RV) and left ventricle (LV) is low because the scatterers (blood cells) slipped off from the focal area of the ultrasonic beam by blood flow. For automated identification of the heart wall using the coherence function, the optimal threshold T0 for the coherence function should be determined. In this study, based on the Bayes decision rule, the optimum value of T0 is determined. Although the coherence function of the region near the anterior wall in the RV is as high as that in the IVS due to echoes from the external tissue resulting from the sidelobe, the artifact can be reduced by removing the static component from RF echoes before evaluation of the coherence function. In vivo experimental results show the differentiation of the heart wall from the lumen was improved using the proposed method.