Didn't understand this concept

Didn’t understand this concept.Can you send some pseudocode or something?

Hey @akash_281 pseudocode is already discussed in video, here is the concept visualization


to obtain
sum of matix of pink = sum(yellow)-sum(red)-sum(green)+sum(shaded region in purple).