The surrounding environment has serious influence on through-the-wall imaging (TWI). The image of behind-the-wall targets will defocus and misplace when neglecting the effect of walls. Cognitive imaging is a recently proposed concept, which is integrated with environment sensing capability and thus suitable for TWI. In this paper, a novel method is proposed to estimate the wall parameters, width and permittivity, to build the environmental model for cognitive imaging of behind-the-wall targets. Firstly, a forward model of electromagnetic wave propagation in a homogeneous wall is developed. Based on the forward model, the estimation of wall parameters is modeled as a least square problem and can be solved efficiently. The simulation data of the finite-difference time-domain method are used to validate our proposed method.