This study investigated the influence of vacuum casting parameters on defects in magnesium alloy as well as changes in the mechanical properties of these alloys and microstructural evolution under the effects of annealing. We used the Taguchi method in conjunction with an X-ray image detector to determine the percentage of area affected by internal defects, the results of which were verified experimentally. X-ray images of magnesium alloy specimens were filtered, binarized, and edge enhanced. The calculated area of internal defects was then used to optimize process parameters according to multiple performance indicators. Based on the average signal-to-noise ratio, Batch 1 (720 • C, 30 torr, 2 h, steel, and 120 min of argon gas injection) and Batch 8 (780 • C, 30 torr, 1 h, steel, and 120 min of argon gas injection) were both deemed optimal. The uniformity in the percentage of internal defect area observed in samples from Batch 8 is an indication of stability.