MATLAB: I have used the code to convert rgb image to binary , need to convert binary back to rgb

binaryImage Processing Toolboximageconversionrgb

RGBi=im2double(imread('autumn.tif'));
imshow(RGBi)
Ii = rgb2gray(RGBi);
imshow(Ii)
bi=imbinarize(Ii);

Best Answer

You cannot convert back from binary to RGB. binary has only one bit of information for each location; RGB has about 24 bits of information for each location.
What you probably want instead is
maskedRGBi = RGBi .* bi(:,:,[1 1 1]);