MATLAB: How I convert all points above a line from 0 to 1

matrix manipulation

The red points represent the line (hLine).
I want convert all points above the red line from 0 to 1.
L.

Best Answer

If the lines were strictly diagonal, then you could make use of tril or triu. For example,
max(Data, triu(ones(size(Data)),-3) )
With non-diagonal lines, then consider using poly2mask. You will need to take into account https://www.mathworks.com/help/images/ref/poly2mask.html#bq508ot
"To specify a polygon that includes a given rectangular set of pixels, make the edges of the polygon lie along the outside edges of the bounding pixels, instead of the center of the pixels."
Related Question