We demonstrate that images of flux vortices in a superconductor taken with a transmission electron microscope can be used to measure the penetration depth and coherence length in all directions at the same temperature and magnetic field. This is particularly useful for MgB$_2$, where these quantities vary with the applied magnetic field and values are difficult to obtain at low field or in the $c$-direction. We obtained images of flux vortices from an MgB$_2$ single crystal cut in the $ac$ plane by focussed ion beam milling and tilted to $45^circ$ with respect to the electron beam about its $a$ axis. A new method was developed to simulate these images which accounted for vortices with a non-zero core in a thin, anisotropic superconductor and a simplex algorithm was used to make a quantitative comparison between the images and simulations to measure the penetration depths and coherence lengths. This gave penetration depths $Lambda_{ab}=100pm 35$ nm and $Lambda_c=120pm 15$ nm at 10.8 K in a field of 4.8 mT. The large error in $Lambda_{ab}$ is a consequence of tilting the sample about $a$ and had it been tilted about $c$, the errors would be reversed. Thus, obtaining the most precise values requires taking images of the flux lattice with the sample tilted in more than one direction. In a previous paper, we obtained a more precise value using a sample cut in the $ab$ plane. Using this value gives $Lambda_{ab}=107pm 8$ nm, $Lambda_c=120pm 15$ nm, $xi_{ab}=39pm 11$ nm and $xi_c=35pm 10$ nm which agree well with measurements made using other techniques. The experiment required two days to conduct and does not require large-scale facilities. It was performed on a very small sample: $30times 15$ microns and 200 nm thick so this method could prove useful for characterising new superconductors where only small single crystals are available.