In high-voltage devices, the demand for the uniform magnetic fields is very high. The existing methods still have shortcomings in terms of optimizing region, complexity, and universality. Herein, we propose a method for designing uniform magnetic fields based on numerical cloud images and machine learning. First, the magnetic-field distribution of the two parallel coils determined using two shape parameters is calculated using finite element software and is drawn. Thereafter, a dataset of 400 cloud images is created with different magnetic induction intensity distributions using different coil-shape parameters. Next, we employ image-processing techniques to extract nine statistical features from the gray-level information in the images. Models are trained through machine learning to predict electrode-shape parameters based on the gray-level image features. Finally, the magnetic-field image of the expected ideal uniform field is artificially set. In addition, the coil-shape parameters from which the uniform magnetic-field is produced are predicted by the models. The optimized design of the two parallel coils improves the magnetic-field uniformity in the axial and radial center regions compared to the Helmholtz coils. The proposed method provides an accurate and new solution for optimizing the design of a uniform magnetic-field.