A new method of compensating for the excess micromotion along two directions in three-dimensional Coulomb crystals is reported in this paper; this method is based on shape control and optical imaging of a Coulomb crystal in a sectioned linear ion trap. The characteristic parameters, such as the ion numbers, temperatures, and geometric factors of different ion crystals are extracted from the images and secular motion excitation spectra. The method of controlling the shape of the ion crystals can be used in cold ion experiments, such as sympathetically cooling, structural phase transitions,and selective-control of ions, etc.