How to identify the target from the grayscale image obtained by the difference between the foreground and the background?

How do you determine the binarization threshold? The threshold determined by T=graythresh() in matlab is determined by the Otsu method. The effect is OK. The interference factors next to the vehicle can be used as digital images after binarization. The morphological expansion corrosion and opening and closing operations are removed

If you want to calculate the area of ??the vehicle in the image, you can basically segment it by jointly processing the image after edge detection and morphology processing and doing a mask operation. The target of the vehicle and the area of ??the entire vehicle