This is a scenario I've come up with to help me understand key images.
Let's say I have Wallet 1 and Wallet 2. Wallet 1 has TXO A and TXO B. I send TXO A and TXO B as inputs to Wallet 2. TXO B was reduced to pay transaction fees. Then I send TXO A and the updated TXO B as inputs back to Wallet 1. TXO B was reduced further to pay transaction fees. What I'm left with that concerns me is TXO A.
Based on my rudimentary knowledge of key images, I know that a key image was generated as part of the first transaction (the send from Wallet 1 to Wallet 2). That key image, in layman's terms, says that Wallet 1 spent TXO A (and TXO B, of course), so it can no longer spend TXO A again.
But now TXO A is back in Wallet 1, unchanged (as far as I know) from its original glory. Will the key image be different the second time around, so that Wallet 1 is not prevented from spending TXO A again? Does the original key image have an effect on the ability of Wallet 1 to spend TXO A the second time?
(Please recall from the title that I'm interested in the ingredients - perhaps "variables" is the technical term - for how a key image is generated.)