MATLAB: Gray image quantization

digital image processingdigital signal processingimage processingMATLABquantizationsignal processing

I am trying to quantize an image into 12 bit intensity using the below code:
R2D = mat2gray(R2D); % intensity between [0,1] Double
R2D = double(uencode(R2D,12)); % intensity between [0,2^12] integer
PIC = mat2gray(R2D); % intensity between [0,1] Double
imshow(pic);
the problem is in 'uencode' function , the input must be in the range of [-1,1], is there a way to do that quantization for input values between [0,1]? may be some changes to the 'uencode' will do job 🙂
Many thanks

Best Answer

Thank you, I found the Solution:
R2D = mat2gray(R2D);
[R2D8,map] = gray2ind(R2D,128);
pic = ind2gray(R2D8,map);
pic = mat2gray(pic);
imshow(pic);
Related Question