PROGRAM 1 : TO CONVERT RGB IMAGE TO GRAY. >> x=imread('1.jpg'); % read image 1.jpg and store as x >> a=rgb2gray(x); % converts x into gray from RGB…