Hi Hina,
As per my understanding, you want to detect the edges on your images and colour the portion below them.
To detect the edge, you can use the “edge” function in MATLAB, in which you can specify which “method” you would like to use for the edge detection along with the “direction” in which you wish to detect edges.
You can use the “sobel” method with “horizontal” direction or change them as per your requirement (whichever gives the best results) and then get the coordinates of these detected edges and then plot them. Since you wish to colour the area below the graph you can use the “area” function in MATLAB.
For more information on the above-mentioned functions, you can refer to the following documentation:
For “edge” function:
For “area” function:
In case you face issues finding the coordinates of the edge you can refer to this answer: