This document presents a novel automated approach for aligning the electron ronchigrams of a scanning transmission electron microscope (STEM) using machine learning and image processing techniques. The approach applies edge detection algorithms to electron ronchigrams to identify their contours and determine alignment quality. A trainable segmentation classifier is trained on example ronchigrams to recognize optimal alignment in new ronchigrams. The goal is to develop a computer program that can automatically align the ronchigram and optimize a STEM's resolution without human intervention.