We show how a combination of X-ray computed tomography (X-CT) and image-based modelling can be used to calculate the effect of moisture content and compaction on the macroscopic structural properties of soil. Our method is based on the equations derived in Daly & Roose (2018 Proc. R. Soc. A474, 20170141), which we have extended so they can be directly applied to the segmented images obtained from X-CT. We assume that the soils are composed of air-filled pore space, solid mineral grains and a mixed phase composed of both clay particles and water. We considered three different initial soil treatments, composed of two different compaction levels and two different moisture contents. We found that the effective properties of the soils were unaffected by compaction over the range tested in this paper. However, changing the moisture content significantly altered the hydraulic and mechanical properties of the soils. A key strength of this method is that it enables the optimization or even design of soils composed from different constituents, with specific mechanical and hydraulic properties.