Prediction of the thermo-mechanical behavior of woven composites necessitates a reliable knowledge of their inner structure. A sufficiently accurate description of the fabric geometry could be obtained using X-ray computed microtomography (µCT) at the mesoscopic scale. However, systematic construction of numerical models from µCT remains a difficult task. To address this challenge, we propose a variational segmentation approach which combines µCT with a prior geometric model that is iteratively improved thanks to a heuristic optimization process. The fidelity of the models with respect to the input µCT is evaluated using a measure of similarity including both gray levels and local directions. Our method allowed to build realistic numerical models of woven fabrics that preserve the prescribed weaving pattern, and that are free of interpenetration, which makes them compatible with further numerical simulations. Using our approach, models of complex woven fabrics, but also of woven composites, could be consistently generated from µCT and can serve as reference models, e.g. to analyze in situ tests by pro-*