How to convert uint16 monochrome image to RGB image

2 views (last 30 days)
Hi,
I want to convert unit16 type monochrome image to RGB image. After searching online I did the following. Following commands work if the image is normal 8 bit, but not for 16 bit. It does the conversion, but I cant view the image using imshow command. Can someone help pls?
X = dicomread('C:\Users\...\Documents\HDR\DiCOM_Images\MR-MONO2-16-knee');
X=256x256 int16
gbImage = repmat(X,[1 1 3]);
gbImage=256x256x3 int16
imShow(gbImage, []); no image

Answers (1)

Image Analyst
Image Analyst on 14 Nov 2013
Try this:
X = mat2gray(X);
rgbImage = cat(3, X, X, X);
imshow(rgbImage); % No [] needed - it doesn't apply for RGB images.
  2 Comments
Chami
Chami on 14 Nov 2013
Thanks !
This works. But this converts the matrix X from unit16 into double type. I want to keep uint16 format/type throughout this conversion process if possible. Or double type can keep all the information and can I convert back to uint16 back again?
Thanks & Regards
Image Analyst
Image Analyst on 14 Nov 2013
Edited: Image Analyst on 14 Nov 2013
MATLAB does not support 16 bit RGB images, I don't believe, at least not as far as for displaying them.

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!