In the meantime, I can give a hint of one way, and that is to use impixel() to get the color, and ones() to create an image with the chosen color. Or you can extract the top line, pass it to rgb2lab() and get the darkest L value to determine the darkest color. Use size() to get the size of the input image if you want the output image to be the same size.
Best Answer