Reputation: 47
I am trying to implement color combine function from a imaging software called metamorph in matlab.I have three uint16 bit files(R,G and B) .I need to convert them to 12 bit and then combine them into a RGB image.metamorph converts the 16-bit files to 12-bit and then creates the RGB image from the three 12-bit files.my code is as follows.I am not quite sure how to go about converting a 16-bit image file to 12-bit.
C1 = imread('metamorph/R.tif',3);
C2 = imread('metamorph/G.tif',3);
C3 = imread('metamorph/B.tif',3);
R=mat2gray(C1);
G=mat2gray(C2);
B=mat2gray(C3);
rgb1=cat(3,R,G,B);
imshow(rgb1)
any help is greatly appreciated.
Thanks
Upvotes: 0
Views: 2983
Reputation: 5024
I don't think MATLAB has a data type for 12 bit (which would be one-and-a-half byte per color per pixel). Of course you can scale you double data to fit into a 12 bit integer:
rgb12= round(rgb1/max(rgb1(:))*(2^12-1)); %# scale & round image values to 12 bit
... but then the real question is what good does that do:
imwrite
can apparently do 12bit JPEG, but I'm unsure if that is 12 bit per color. Upvotes: 1