Radio tomographic imaging (RTI) is a main method in device-free localization (DFL) that can locate a target by analyzing its shadowing effect on wireless links, while removing the requirement of equipping the target with a device. The accuracy of RTI method closely depends on the accuracy of shadowing weight model, which represents the relationship between the shadowing effect of the target on wireless links and target location. However, most existing models have not been accurate enough for many applications since they cannot explain some phenomena observed in DFL practices. To overcome the shortcoming of the existing weight model, this paper proposes a gradual-changing weight model to enhance the imaging quality of RTI. Meanwhile, a foreground target detection algorithm based on the shape feature of the target image is proposed to reduce the negative impact of background noises and pseudo-targets, thereby further enhancing the localization accuracy. The indoor and outdoor experimental results highlight the advantages of using the proposed method in improving the imaging quality and the positioning accuracy.