MATLAB: How To remove black color from gray-scale image

blackchange colorgraygrayscaleimage processing

Hi guys
i was wondering how can i remove a black color from the grayscale image? or can i just change the black into any other lighter color?
thank you

Best Answer

It depends on the format of the image. For a UINT8 array:
Img = randi([0,255], 100, 100, 'uint8'); % Test data
Img(Img == 0) = 127;
Now black is replaced by a medium grey. The procedure for double format is equivalent, but a medium grey is 0.5.
Related Question