With matlab, I don\'t know how patch can make gradient color vertically in this picture. Here I just want a simple color gradient. I have used bwboundaries to catch the edge fu
Following Shai's code in his answer in your other question:
  %% Load image %%
close all; clear all; clc;
img = imread('https://i.stack.imgur.com/yO8Nd.jpg');  %// read image
bw = img(:,:,1) > 128;  %// convert to binary mask
lb = bwlabel(bw,4);  %// extract distinct regions
%%
%% Create as many colors as needed
% example: 2
cmap=rand(2,3);  % make this yellow if needed
% lets convert to HSV, we can tune the intesity of the image better here
cmap=rgb2hsv(cmap);
% for each color, lets crate a set of colors.
for ii=1:size(cmap,1);
       colors{ii}= [cmap(ii,1)*ones(1,size(img,2)); cmap(ii,2)*ones(1,size(img,2)); linspace(0.3,1,size(img,2))].';
       %  Modify the limits of linspace
       % to achieve control over the limits
end
% Now we have the colors, lets create an image of vertical colors and mask
% it
cimage=zeros(size(img,1),size(img,2),3); % empthy color image
finalimage=cimage;
for ii=1:size(colors,2)
    colors{ii}=hsv2rgb(colors{ii});
    cimage=permute(reshape(repmat(colors{ii},[size(img,1),1,1]),[size(img,2),size(img,1),3]),[2,1,3]); % there is probably a simpler way 
    finalimage=finalimage+cimage.*repmat((lb==ii),[1 1 3]);
end
figure; imshow(finalimage, [], 'border', 'tight'); 
If you understand the code properly, you will be able to do it for vertical gradient. I accidentally did horizontal, but should be alright. The code is commented, but do not hesitate to ask. The steps are the following
V values, that represent "light"