MATLAB: How to convert a range of pixel values to another range(0-255)

grayscaleimageImage Processing Toolboxmedical image processing

I have a DICOM image in which pixel values ranges from -2000 to 2666. I need to convert those values to ones which are within the grayscale range. How can i do this?

Best Answer

Try mat2gray(), which converts any matrix to a 0-1 range. Then multiply by 255 and cast to uint8 if you want a uint8 data type.
uint8Image = uint8(255 * mat2gray(yourDicomImage));