Since I wrote this question, I have the following answer for the below. Is my answer true?
pM is only 1s and 0s for every pixel in the mask, denoting whether it is inside the region taken out of the image or not. Therefore in the calculation, we keep or remove the contribution of those terms in the structure tensor by checking whether the pixels used in the calculation are present.
(writing all my doubts… in hope that I can get them resolved
)
In gmic.cpp lines 1259-1263 : (https://github.com/dtschump/gmic-minimal/blob/master/src/gmic.cpp)
cimg_forC(pP,c) cimg_for3x3(pP,p,q,0,c,I,T) {
// Compute weight-mean of structure tensor inside patch.
cimg_get3x3(pM,p,q,0,0,_M,unsigned char);
const float
ixf = (float)(_Mnc*_Mcc*(Inc - Icc)),
iyf = (float)(_Mcn*_Mcc*(Icn - Icc)),
ixb = (float)(_Mcc*_Mpc*(Icc - Ipc)),
Isn’t _Mcc same as Icc since the 3x3 neighbourhood around (p,q) (obtained by _get3x3) is anyways obtained through the loop on pM into I ?