Open In App

How to Perform Random Pseudo Coloring in Grayscale Image Using MATLAB?

Pseudo Coloring is one of the attractive categories in image processing. It is used to make old black and white images or videos colorful. Pseudo Coloring techniques are used for analysis identifying color surfaces of the sample image and adaptive modeling of histogram black and white image. Selecting different values in the layers R, G, B is the most important achievement of this technique such that this method is based on the analysis of histogram characteristics in the sample image, to assign different values in different layers of a color image, we take action. Pseudo-coloring is also known as a coloring topic in processing digital images. 

In this technique, a gray level of type integer unsigned 8-bit (a number between zero and 255) should be considered as input and three outputs must be achieved for three layers of the color digital image graph and each of these three levels should be of type integer unsigned 8-bit (a number between zero and 255). There are many techniques for this conversion that have some differences based on our needs.



 

Steps:

Functions Used: 



Example:

% MATLAB code for pseudo colouring
% of grayscale images.
% UTILITY CODE
k=imread("gfglogo.png");
gray2rgb(k);
imtool(grayscale,[]);
function gray2rgb(img)
  
% Convert into grayscale if not.
[x,y,z]=size(img);
if(z==3)
    grayscale=rgb2gray(img);
end
gray=double(grayscale./255);
rgb(:,:,1)=gray(:,:)*0.5;
rgb(:,:,2)=gray(:,:)*0.6;
rgb(:,:,3)=gray(:,:)*0.4;
imtool(rgb,[]);
  
c(x,y,z)=0;
colour=uint8(c);
colour(:,:,1)=grayscale(:,:)*0.5;
colour(:,:,2)=grayscale(:,:)*0.7;
colour(:,:,3)=grayscale(:,:)*0.4;
imtool(colour,[]);
  
pause(10);
imtool close all;
end

                    

Output:

 

 

Code Explanation:


Article Tags :