I’m reading the source code of Telea Inpaint method. The grandiant calculate code makes me confused.
/modules/photo/src/inpaint.cpp #319
if (CV_MAT_ELEM(*f,uchar,k,l+1)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
gradI.x=(float)((CV_MAT_3COLOR_ELEM(*out,uchar,km,lp+1,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km,lm-1,color)))*2.0f;
} else {
gradI.x=(float)((CV_MAT_3COLOR_ELEM(*out,uchar,km,lp+1,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km,lm,color)));
}
}
gradI.x is calculated here. If (k, l+1) and (k, l-1) are not INSIDE (known points), the gradiant is calculated as pixel [ (k, l+1) - (k, l-1) ]* 2. But I think it should be [ (k, l+1) - (k, l-1) ]* 0.5. Because the code below, calculate the gradiant as (k, l+1) - (k, l) .
I wonder if this is a bug or some other process strategy I didn’t understand.