Semaphore Sam is onto something
I regularly go through the same checkpoint. I always used to have to dig in my bag and bring out the shaving foam everytime they spotted it on the X-ray.
Once they saw the can they used to say "OK you can take it"
I could never figure out what they coould gain by looking at the can that did not come up on the X-ray (other than to p*ss me off by having to open my bag)
I tried extreme compliance and everytime they asked me to show them the can I insited on showing them it REALLY was shaving foam. That is, I sprayed a big pile of it all over their desk and thanked them for being so through in checking my bag.
I am now rarely asked to physically remove the can from my bag