You do tmi -= background, followed by tmi += background; that is optimal wrt. memory usage, but (I think) it may make the resulting tmi different from the starting one, if background was funny (e.g., if it had a pixel with a large number, or a NaN, etc.). None of these should (I think) show up during normal processing, but if they do (e.g., because of a bug in background estimation), they may throw you off while debugging (you may think that the issue is with data in tmi).