I've had a similar problem. Here is what I did:
In your case, if the proportions are always the same, then you can simply keep the biggest component.
You can use a shape descriptor that is rotation,scale and translation invariant like Hu moments.
Calculate the shape descriptor of the wanted shape from one image that you filtered manually (Form the image above just take the biggest connected component)
For each new image calculate the matchShapes for each one of the connected component and the original Hu moments and take the connected component that got the lowest value(which is the closest shape).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.