https://ch.mathworks.com/help/images/ref/gradientweight.html
gradientweight - Calculate weights for image pixels based on image gradient - MATLAB
This MATLAB function calculates the pixel weight for each pixel in image I based on the gradient magnitude at that pixel, and returns the weight array W.
based oncalculateweightsimagepixels