I added a comment to explain how it works.  I used this as I saw this was the way it was done in denoiseprofile and nlmeans for example.    But if you prefer, I can define a new struct so that the changes are more explicit.